Skip to content

Instantly share code, notes, and snippets.

@ralexandr
Last active June 20, 2020 23:55
Show Gist options
  • Select an option

  • Save ralexandr/5ccdc4d28f43bbf8fe5ed8320584e7ef to your computer and use it in GitHub Desktop.

Select an option

Save ralexandr/5ccdc4d28f43bbf8fe5ed8320584e7ef to your computer and use it in GitHub Desktop.

Revisions

  1. ralexandr revised this gist Jun 20, 2020. 1 changed file with 20 additions and 1 deletion.
    21 changes: 20 additions & 1 deletion nginx.cors.settings.conf
    Original file line number Diff line number Diff line change
    @@ -11,4 +11,23 @@ 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$
    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;
    }
    }
  2. ralexandr renamed this gist Jun 20, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. ralexandr created this gist Jun 20, 2020.
    14 changes: 14 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    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$