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

Fix InvalidCrossOriginRequest response #3459

Merged
merged 1 commit into from
Apr 25, 2019

Conversation

javierm
Copy link
Member

@javierm javierm commented Apr 25, 2019

References

Objectives

Fix an ActionController::InvalidCrossOriginRequest exception we were getting when requesting non-existent JavaScript files.

When requesting files like `/hackattempt.js`, the pages controller was
responding with 404 status code.

However, since the request was considered a JavaScript request (because
of the `.js` extension), the response was also considered to be a
JavaScript one, and since the request wasn't an AJAX request, our
protection from forgery was preventing a potential security issue by
raising an InvalidCrossOriginRequest exception.

By setting HTML as content type, we correctly respond with a 404 status
code.

More info:

https://die-antwort.eu/techblog/2018-08-avoid-invalid-cross-origin-request-with-catch-all-route/
@javierm javierm self-assigned this Apr 25, 2019
@javierm javierm merged commit e0484e4 into master Apr 25, 2019
@javierm javierm deleted the backport-fix_cross_origin_exception branch April 25, 2019 20:02
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.

2 participants