This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Hey guys, so i've been stuck on this problem for awhile now... cant seem to find a problem.
I created api server using nginx and python flask and another server on different ip address is running a web server crated with react.
I got to a point I have added cors stuff to my nginx. so when I
curl -v my.domain.com/some/endpoint
< Server: nginx/1.14.0 (Ubuntu)
< Date: Fri, 20 Mar 2020 04:51:42 GMT
< Content-Type: text/html; charset=utf-8
< Content-Length: 178
< Connection: keep-alive
< Allow: POST, OPTIONS
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Headers: Content-Type,Authorization
< Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS
< Access-Control-Allow-Credentials: true
I get this result... But when i try to POST something on to the server i still seem to get cors error... have i done something wrong?
This is my /etc/nginx/sites-available/site location codes
location / {
# include /etc/nginx/cors-settings.conf;
include uwsgi_params;
uwsgi_pass unix:///root/io-backend/main.sock;
add_header "Access-Control-Allow-Origin" *;
add_header "Access-Control_Allow-Methods" "GET, POST, OPTIONS";
# Preflighted requests
if ($request_method = OPTIONS ) {
add_header "Access-Control-Allow-Origin" *;
add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, HEAD";
add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept";
return 200;
}
I cant seem to get a grasp whether this is still nginx problem or my python code problem... I do have Flask-CORS enabled on my backend tho.
Any help would be greatly appreciated... been stuck on this for a while now
Post Details
- Posted
- 4 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/nginx/comme...