Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Lunr: Content Security Policy (CSP), X-Content-Type: nosniff #82

Closed
strauhmanis opened this issue Nov 30, 2018 · 3 comments
Closed

Lunr: Content Security Policy (CSP), X-Content-Type: nosniff #82

strauhmanis opened this issue Nov 30, 2018 · 3 comments

Comments

@strauhmanis
Copy link

Hi!

I have the following CSP header:

X-Content-Type-Options: nosniff

With this content security policy enabled, the following error comes up in web inspector console (I'm using local (non Ruby gem method), untouched, Basically Basic theme files):

[Error] Refused to execute https://www.mydomain.com/assets/javascripts/search-data.json as script because "X-Content-Type: nosniff" was given and its Content-Type is not a script MIME type.

I would like to ask if that is something that can be fixed within the scope of this project, or if this error can be dealt with otherwise, without disabling the mentioned CSP header.

Thanks!

@mmistakes
Copy link
Owner

Don't think there is anything to fix within the scope of this project. This appears to be hosting related, which the theme has no control over.

@strauhmanis
Copy link
Author

Got it. Thanks!

@qgustavor
Copy link
Contributor

qgustavor commented Aug 2, 2019

Woudn't be better changing search-data.json to search-data.js like mmistakes/minimal-mistakes/assets/js/lunr/lunr-store.js? The extension is wrong: it isn't a JSON file, is a JavaScript file. It would fix the wrong mime-type and avoid mime related issues.

Surely, it only causes issues when content-type-options: nosniff is added by the server so I'm trying to find why my server is adding it and CloudFlare was adding it. In the other hand, as it is a security feature, renaming this file would be a better fix.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants