A
A
Adel Khalitov2019-08-05 23:57:48
linux
Adel Khalitov, 2019-08-05 23:57:48

How to run nodejs on linux server?

I bought the simplest VPS.
Installed nginx.
I riveted a page on angular, from which an http request is made to localhost: 3001
(configured nginx for angular files, everything works ok)

server {
                server_name some.ru www.some.ru;
                root /var/www/buhgalter/mother-buh/;
        }

Deployed a nodejs server on port 3001
I go to www.some.ru, make a request and get an error:
net::ERR_CONNECTION_REFUSED (chrome)
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at localhost:3001/api/ public/sendmail. (Reason: CORS request did not succeed). (FireFox)
Addblock disabled.
Cron is configured, accepts any requests from any address.
Given the above, I can conclude that the request does not reach port 3001.
What is the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Shumov, 2019-08-06
@adelkhalitov

What is today, CORS day? In 100500 times - the browser will not allow you to contact just like that through js from one domain to another. Either set the server as a back to a route in the same domain, or set the correct allow origin headers.
Well, in pursuit - for the localhost browser, this is always the user's machine, but not your vps

O
oh, 2017-12-11
well @AnneSmith

dividing by 1000 can lead to problems with the value, it is
better to remove the last three characters with lowercase functions
in order to correctly work with dates, you need to sit down and carefully read the docs and look for working examples, there are always a lot of surprises like daylight saving time :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question