Quantcast
Channel: User Misha Krul - Stack Overflow
Viewing all articles
Browse latest Browse all 42

Reverse proxy CORS Configuration for NGINX

$
0
0

I have a nodejs server and react client app deployed to an ec2 instance. When I try to send a POST request to /api/emails route it returns a CORS / CORB error in the console.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:9001/api/email. (Reason: CORS request did not succeed).

My app-server nginx configuration looks like:

server {  listen 80;  listen [::]:80;  server_name ec2-52-202-82-153.compute-1.amazonaws.com;  location / {        proxy_pass http://127.0.0.1:9001/;        proxy_set_header X-Real-IP $remote_addr;        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;        proxy_set_header X-NginX-Proxy true;        proxy_ssl_session_reuse off;        proxy_set_header Host $http_host;        proxy_redirect off;        proxy_set_header 'Access-Control-Allow-Origin''*';        proxy_set_header 'Access-Control-Allow-Credentials' true;     }}

My app-client configuration looks like:

server {  listen 80;  listen [::]:80;  server_name ec2-52-202-82-153.compute-1.amazonaws.com;        location / {                proxy_pass http://127.0.0.1:9002;        }}

Viewing all articles
Browse latest Browse all 42

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>