Last active
June 20, 2020 23:55
-
-
Save ralexandr/5ccdc4d28f43bbf8fe5ed8320584e7ef to your computer and use it in GitHub Desktop.
nginx.cors.settings.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "Upgrade"; | |
proxy_set_header X-Frappe-Site-Name erp.example.pro; | |
proxy_set_header Origin $scheme://$http_host; | |
proxy_set_header Host $host; | |
proxy_pass http://frappe-bench-socketio-server; | |
add_header 'Access-Control-Allow-Origin' '*' always; | |
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always; | |
add_header 'Access-Control-Allow-Credentials' 'true' always; | |
add_header 'Access-Control-Allow-Headers' 'DNT, Authorization, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, Content-Type, Content-Length'; | |
add_header 'Access-Control-Expose-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modi$ | |
...OR... | |
location ~ ^/index\.php(/|$) { | |
... | |
add_header 'Access-Control-Allow-Origin' "$http_origin" always; # if you change "$http_origin" to "*" you shoud get same result - allow all domain to CORS (but better change it to your particular domain) | |
add_header 'Access-Control-Allow-Credentials' 'true' always; | |
if ($request_method = OPTIONS) { | |
add_header 'Access-Control-Allow-Origin' "$http_origin"; # DO NOT remove THIS LINES (doubled with outside 'if' above) | |
add_header 'Access-Control-Allow-Credentials' 'true'; | |
add_header 'Access-Control-Max-Age' 1728000; # cache preflight value for 20 days | |
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; # arbitrary methods | |
add_header 'Access-Control-Allow-Headers' 'My-First-Header,My-Second-Header,Authorization,Content-Type,Accept,Origin'; # arbitrary headers | |
add_header 'Content-Length' 0; | |
add_header 'Content-Type' 'text/plain charset=UTF-8'; | |
return 204; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment