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

is there a way to add wildcard ports for the origins? #17

Closed
linus-amg opened this issue Aug 19, 2015 · 3 comments
Closed

is there a way to add wildcard ports for the origins? #17

linus-amg opened this issue Aug 19, 2015 · 3 comments

Comments

@linus-amg
Copy link

i have domain.tld or domain.tld:3000 acessing the ressource and i want both to be allowed, but in the origins i would like to specify domain.tld:* or something like that..

@linus-amg
Copy link
Author

or maybe even domain.tld:80,3000 or domain.tld:80-3000

@agrueneberg
Copy link
Owner

Thanks for the feedback! Unfortunately, the Access-Control-Allow-Origin header doesn't support port wildcards for particular domains (see #2 for a similar issue regarding Access-Control-Allow-Headers and Access-Control-Expose-Headers). I'm not a big fan of adding a special wildcard syntax in Corser because it would mean that I would have to inflate domain.tld: for all 2^16 ports--something that I'm sure no one would want in their HTTP headers. Is either hardcoding the port numbers, or reading them from a config file an option?

domain = "domain.tld";
ports = [80, 3000];
listener = corser.create({
    origins: ports.map(function (p) {
        return domain + ":" + p;
    })
});

@linus-amg
Copy link
Author

instead of the raw req.origin you could parse the hostname out of it, so http://app.test.com:3000 gets app.test.com and then you check the origins array ['app.test.com'] for an indexOf > -1. as an example, what do you think of that idea? like that, the port does not matter anymore, rfc specificly i guess that there should still be a way to not allow a certain port but another one instead, so for that.. it wouldnt work :(
maybe everything should stay exactly the same it is.. your way of using a function for that should be good enough for solving my problem.

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