Skip to content

Fix Access-Control-Allow-Headers to match exact headers #390

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

Conversation

workslon
Copy link
Contributor

Access-Control-Allow-Headers doesn't allow wildcards.
http://stackoverflow.com/a/13147554

@@ -132,7 +132,7 @@ function handleParseHeaders(req, res, next) {
var allowCrossDomain = function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.header('Access-Control-Allow-Headers', '*');
res.header('Access-Control-Allow-Headers', 'X-Parse-REST-API-Key, X-Parse-Javascript-Key, X-Parse-Application-Id, X-Parse-Client-Version, X-Parse-Session-Token, X-Requested-With, X-Parse-Revocable-Session, Content-Type');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the keys limited because it's only for browser-based requests? (i.e. no master key header).. If so, not sure the REST header should be included?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right, it is for browser requests only.
I just copied the headers from the api.parse.com response headers - not sure if we need all of them. Important is to allow the "X-Parse-Application-Id" one.
Thx!

@gfosco
Copy link
Contributor

gfosco commented Feb 16, 2016

From the stackoverflow link, how about we use the value in the Access-Control-Request-Headers property to function as a wildcard?

@workslon
Copy link
Contributor Author

Access-Control-Request-Headers - A comma-delimited list of non-simple headers that are included in the request.

Unfortunately, server will verify and accept only headers explicitly listed in the 'Access-Control-Allow-Headers'. As long as custom headers (such as 'X-Parse-Application-Id') are used they must be listed in 'Access-Control-Allow-Headers' - it is CORS requirement.

drew-gross added a commit that referenced this pull request Feb 19, 2016
…ders-response-header

Fix Access-Control-Allow-Headers to match exact headers
@drew-gross drew-gross merged commit 941984f into parse-community:master Feb 19, 2016
@drew-gross
Copy link
Contributor

Thanks for the PR!

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.

4 participants