Hello!
I am having a thus far unsurmountable issue with enabling my website, hosted at /var/www/html/, from sending a json object via an ajax post request through a hmtl file to a plumber api I have listening at droplet-ip:3000/myApi. I have configured my plumber api config file in etc/nginx/sites-available/ as follows:
location /myApi/ {
proxy_pass http://localhost:3000/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
}
I have my plumber.R file configured with
"Access-Control-Allow-Origin", "*"
And I have a firewall enabled for this droplet with port 8000 and 3000 tcp and udp access.
The error I am still receiving is:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://droplet-ip:3000/myApi. (Reason: CORS request did not succeed). Status code: (null).
Any help here is so very much appreciated! Cheers.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi @friendlylightseagreeneel,
I’ve read a bit more on the subject of passing some values to a reverse proxy API. A few times I’ve seen the following examples:
Of course this includes all the necessary options needed. What you can use is :
An alternative would be:
Hope that helps!