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

Support wildcard subdomains #54

Open
thiamsantos opened this issue Aug 22, 2018 · 2 comments
Open

Support wildcard subdomains #54

thiamsantos opened this issue Aug 22, 2018 · 2 comments

Comments

@thiamsantos
Copy link
Contributor

It is possible to pass a list with wildcard domain as valid origins?

config :cors_plug,
  origin: ["https://*.example.com", "http://*.example.com"]
@mschae
Copy link
Owner

mschae commented Aug 23, 2018

Not exactly, wildcard domains are not part of the CORS spec.

I’d recommend a regex tho:

config :cors_plug, origin: ~r{^https?://\w+\.example\.com$}

@thiamsantos
Copy link
Contributor Author

@mschae we have been using regex so far. However we are in the process of migration to distillery, and we will use a toml file as config in the production environment. Toml files do not support regex, only primitives types. So would be a cool feature on cors_plug to support wildcard domains, even if it is not a part of the CORS spec. I would be happy to send PR implementing this feature.

Right now, we will use a custom config that will convert the wildcards to regex and pass the origins directly to the plug itself. I think it will solve the problem for us.

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