Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added CORS support for rev-proxy APIs #49

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

siexp
Copy link
Contributor

@siexp siexp commented Jul 13, 2021

Added new flag allow_cors: <bool> which enables Cross-Origin requests for proxied API. Without this flag enabled only requests from the same to Api host domains are allowed in browser.

nginx_revproxy_sites:
  example.com:
    ...
    allow_cors: <bool | default( false )>

When enabled force nginx to add following headers to response

   add_header 'Access-Control-Allow-Origin' $http_origin;
   add_header 'Access-Control-Max-Age' 600;

Access-Control-Allow-Origin set to $http_origin which is equal to value from Origin header in request
Access-Control-Max-Age set to 10 min period accordingly to Chromium v76 and below cap

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant