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

Add CORS Support #28

Open
scotthelm opened this issue Mar 19, 2017 · 4 comments
Open

Add CORS Support #28

scotthelm opened this issue Mar 19, 2017 · 4 comments

Comments

@scotthelm
Copy link
Contributor

I am using docker-compose for a web API. I am developing a javascript front-end in a separate docker-compose project. I found that CORS was not enabled for the API endpoint. In a fork, I have added support for CORS to the nginx.tmpl. I am now able to reach the API from the front-end via CORS enabled xhr request.

I have a PR ready if you would like to consider adding CORS support.

@codekitchen
Copy link
Owner

I've found that we typically end up setting the CORS headers in our apps, not in a of web proxy, so that we have more dynamic control over how the headers are generated. Adding CORS support in this proxy sounds good, but we'll want it optional behind an environment variable or some other means, since enabling it by default would interfere with testing app-defined CORS functionality.

@scotthelm
Copy link
Contributor Author

I have added a conditional check for a container's CORS_ENABLED environment variable. If present and parsed as true, then the CORS block will be enabled for that container's config.

e.g.

// docker-compose.yml
...
services:
  api:
    environment:
      - CORS_ENABLED=true
  web:
    environment:
      - ...

would enable CORS for api nginx config, while leaving CORS headers off web nginx config

@codekitchen
Copy link
Owner

sweet, sounds great. please add something to the configuration section of the README when you send over the PR, as well. thanks!

@scotthelm
Copy link
Contributor Author

I have added #29

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

No branches or pull requests

2 participants