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

Allow regex CORS config #2762

Closed
mejiaej opened this issue Feb 10, 2021 · 3 comments · Fixed by #2823
Closed

Allow regex CORS config #2762

mejiaej opened this issue Feb 10, 2021 · 3 comments · Fixed by #2823
Assignees
Labels
Companion The auth server (for Instagram, GDrive, etc) and upload proxy (for S3) Feature

Comments

@mejiaej
Copy link
Contributor

mejiaej commented Feb 10, 2021

Hi, in my organization we are running a companion server with CORS config using the COMPANION_CLIENT_ORIGINS env variable. We also have a staging server in which we deploy under different dynamic subdomains depending on the branch name.

Is there a chance we can allow the env variable to support regex?

Here is a regex config that could work for a subdomain scenario:

https://.*.maindomain.(com|eu)$

these subdomains should pass that config:

-https://branch1Subdomain.maindomain.com
-https://branch2Subdomain.maindomain.com
-https://branch3Subdomain.maindomain.eu

@arturi
Copy link
Contributor

arturi commented Feb 11, 2021

What do you think @tim-kos @mifi?

@arturi arturi added Companion The auth server (for Instagram, GDrive, etc) and upload proxy (for S3) and removed Triage labels Feb 11, 2021
@mifi
Copy link
Contributor

mifi commented Feb 11, 2021

Maybe we can instead just use the cors module and just pass the option to that module. It supports array, regex etc out of the box

https://github.com/expressjs/cors#configuration-options

@goto-bus-stop
Copy link
Contributor

I was going to suggest supporting *.maindomain.com style wildcards instead, but if the cors module accepts regexes we may as well just follow/expose that

mifi added a commit that referenced this issue Mar 21, 2021
- adds support for regex COMPANION_CLIENT_ORIGINS_REGEX
- encapsulate custom cors header merge logic in own middleware
- pull out non cors logic from middleware
- unit test the cors middleware
arturi pushed a commit that referenced this issue Mar 26, 2021
* use cors module instead of custom cors logic #2762

- adds support for regex COMPANION_CLIENT_ORIGINS_REGEX
- encapsulate custom cors header merge logic in own middleware
- pull out non cors logic from middleware
- unit test the cors middleware

* fix capitalization

Co-authored-by: Julian Gruber <julian@juliangruber.com>

Co-authored-by: Julian Gruber <julian@juliangruber.com>
HeavenFox pushed a commit to docsend/uppy that referenced this issue Jun 27, 2023
* use cors module instead of custom cors logic transloadit#2762

- adds support for regex COMPANION_CLIENT_ORIGINS_REGEX
- encapsulate custom cors header merge logic in own middleware
- pull out non cors logic from middleware
- unit test the cors middleware

* fix capitalization

Co-authored-by: Julian Gruber <julian@juliangruber.com>

Co-authored-by: Julian Gruber <julian@juliangruber.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Companion The auth server (for Instagram, GDrive, etc) and upload proxy (for S3) Feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants