wiki:allowing_cors_requests
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| wiki:allowing_cors_requests [2024/10/11 07:52] – [Allowing CORS requests] add scrot of error antisa | wiki:allowing_cors_requests [2026/09/15 10:54] (current) – [Allowing CORS requests] add info about only needing one type of requests antisa | ||
|---|---|---|---|
| Line 10: | Line 10: | ||
| Below is a config for preflighted and simple requests which will allow requests (e.g. from fetch function in browser console) from **example.org** domain to the domain **example.com** | Below is a config for preflighted and simple requests which will allow requests (e.g. from fetch function in browser console) from **example.org** domain to the domain **example.com** | ||
| + | |||
| + | <WRAP center round info 60%> | ||
| + | You might only need the preflighted requests (if clause) if you notice duplicate **access-control-** headers being returned. | ||
| + | </ | ||
| + | |||
| ===== nginx ===== | ===== nginx ===== | ||
| Line 27: | Line 32: | ||
| ... | ... | ||
| if ($request_method = ' | if ($request_method = ' | ||
| - | add_header ' | + | |
| - | add_header ' | + | add_header ' |
| - | add_header ' | + | add_header ' |
| - | add_header ' | + | add_header ' |
| - | add_header ' | + | add_header ' |
| - | return 204; | + | return 204; |
| - | | + | } |
| + | add_header ' | ||
| add_header ' | add_header ' | ||
| - | add_header ' | + | add_header ' |
| - | add_header ' | + | add_header ' |
| - | add_header ' | + | |
| ... | ... | ||
| Line 45: | Line 51: | ||
| proxy_http_version 1.1; | proxy_http_version 1.1; | ||
| proxy_set_header Connection ""; | proxy_set_header Connection ""; | ||
| + | | ||
| + | # Ensure cookies and headers pass correctly | ||
| + | proxy_pass_request_headers on; | ||
| + | proxy_set_header Cookie $http_cookie; | ||
| } | } | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | <WRAP center round tip 60%> | ||
| + | If you are also setting a cookie, remember that it can only be set from the same domain i.e. if there' | ||
| + | </ | ||
| ====== Tested on ====== | ====== Tested on ====== | ||
wiki/allowing_cors_requests.1728633173.txt.gz · Last modified: by antisa
