Advertisement
TaPTaK

Untitled

Aug 7th, 2020
2,637
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 3.13 KB | None | 0 0
  1. if ($request_method = 'OPTIONS') {
  2.             add_header 'Access-Control-Allow-Origin' '*' always;
  3.             #
  4.             # Om nom nom cookies
  5.             #
  6.             add_header 'Access-Control-Allow-Methods' 'GET, POST, PATCH, PUT, DELETE, OPTIONS';
  7.             #
  8.             # Custom headers and headers various browsers *should* be OK with but aren't
  9.             #
  10.             add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  11.             #
  12.             # Tell client that this pre-flight info is valid for 20 days
  13.             #
  14.             add_header 'Access-Control-Max-Age' 1728000;
  15.             add_header 'Content-Type' 'text/plain charset=UTF-8';
  16.             add_header 'Content-Length' 0;
  17.             add_header Access-Control-Allow-Headers "Authorization";
  18.             add_header Access-Control-Allow-Credentials "true";
  19.             return 204;
  20.         }
  21.         if ($request_method = 'PUT') {
  22.             add_header 'Access-Control-Allow-Origin' '*' always;
  23.             add_header 'Access-Control-Allow-Credentials' 'true';
  24.             add_header 'Access-Control-Allow-Methods' 'GET, POST, PATCH, PUT, DELETE, OPTIONS';
  25.             add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  26.         }
  27.         if ($request_method = 'PATCH') {
  28.             add_header 'Access-Control-Allow-Origin' '*' always;
  29.             add_header 'Access-Control-Allow-Credentials' 'true';
  30.             add_header 'Access-Control-Allow-Methods' 'GET, POST, PATCH, PUT, DELETE, OPTIONS';
  31.             add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  32.         }
  33.         if ($request_method = 'POST') {
  34.             add_header 'Access-Control-Allow-Origin' '*' always;
  35.             add_header 'Access-Control-Allow-Credentials' 'true';
  36.             add_header 'Access-Control-Allow-Methods' 'GET, POST, PATCH, PUT, DELETE, OPTIONS';
  37.             add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  38.         }
  39.         if ($request_method = 'GET') {
  40.             add_header 'Access-Control-Allow-Origin' '*' always;
  41.             add_header 'Access-Control-Allow-Credentials' 'true';
  42.             add_header 'Access-Control-Allow-Methods' 'GET, POST, PATCH, PUT, DELETE, OPTIONS';
  43.             add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  44.         }
  45.         if ($request_method = 'DELETE') {
  46.             add_header 'Access-Control-Allow-Origin' '*' always;
  47.             add_header 'Access-Control-Allow-Credentials' 'true';
  48.             add_header 'Access-Control-Allow-Methods' 'GET, POST, PATCH, PUT, DELETE, OPTIONS';
  49.             add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  50.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement