User Tools

Site Tools


wiki:allowing_cors_requests

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
wiki:allowing_cors_requests [2024/10/14 14:42] – [nginx] add info about Set-Cookie antisawiki: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.
 +</WRAP>
 +
  
 ===== nginx ===== ===== nginx =====
Line 28: Line 33:
 if ($request_method = 'OPTIONS') { if ($request_method = 'OPTIONS') {
   add_header 'X-preflighted' 'true';   add_header 'X-preflighted' 'true';
-  add_header 'Access-Control-Allow-Origin' example.org always;+  add_header 'Access-Control-Allow-Origin' https://example.org always;
   add_header 'Access-Control-Allow-Credentials' 'true';   add_header 'Access-Control-Allow-Credentials' 'true';
   add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept, Authorization';   add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept, Authorization';
Line 35: Line 40:
 } }
  
-add_header 'Access-Control-Allow-Origin' example.org always;+add_header 'Access-Control-Allow-Origin' https://example.org always;
 add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Credentials' 'true';
 add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept, Authorization'; add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept, Authorization';
wiki/allowing_cors_requests.1728916964.txt.gz · Last modified: by antisa

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki