Answer the question
In order to leave comments, you need to log in
How to bypass CORS?
1) I raised the API service on the node, port 5000.
I access it like this:
127.0.0.1:5000/api/v1/categories/all
2) the client is launched at 127.0.0.1:81 and it sends an AJAX request to our server.
swears at CORS
Tell me pliz how to do it right so that I don’t swear at CORS?
Maybe some kind of proxying on the node or NGINX is there?
I got it through Access-Control-Allow-Origin, but I would like somehow without this header ...
Answer the question
In order to leave comments, you need to log in
Solving the problem with nginx .
Write the application host in /etc/hosts :
In nginx.conf in the server section :
server {
listen 80;
server_name my-app;
location ^~ / {
proxy_pass http://localhost:81/;
}
location ^~ /api/ {
proxy_pass http://localhost:5000/api/;
}
}
http://my-app
and to the API in the application as http://my-app/api
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question