Skip to content

Instantly share code, notes, and snippets.

@navix
Last active March 5, 2017 07:30
Show Gist options
  • Select an option

  • Save navix/85071e40d387de5cd2e5608413b3e58b to your computer and use it in GitHub Desktop.

Select an option

Save navix/85071e40d387de5cd2e5608413b3e58b to your computer and use it in GitHub Desktop.
PE Local dev auth

Send requests with credentials

let requestOptions: RequestOptionsArgs = {
  ...
  withCredentials: true,

Send correct headers from server

...
location / {
  if ($request_method = 'OPTIONS') {
    add_header 'Access-Control-Allow-Origin' 'http://localhost:8080';
    add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE, PATCH';
    add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
    add_header 'Access-Control-Max-Age' 1728000;
    add_header 'Content-Type' 'text/plain charset=UTF-8';
    add_header 'Content-Length' 0;
    add_header 'Access-Control-Allow-Credentials' 'true';
    return 204;
  }
  ...
}
...
location ~ ^/app\.php(/|$) {
  ...
  add_header 'Access-Control-Allow-Origin' 'http://localhost:8080';
  add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  add_header 'Access-Control-Allow-Credentials' 'true';
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment