Reputation: 7597
I get errors like:
10:24:45.375 localhost/:1 Refused to execute script from 'https://localhost/runtime.a66f828dca56eeb90e02.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.
10:24:45.390 localhost/:1 Refused to execute script from 'https://localhost/polyfills.2f4a59095805af02bd79.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.
10:24:45.391 localhost/:1 Refused to execute script from 'https://localhost/main.4946ee69e21757a0ea38.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.
10:24:50.815 localhost/:1 Refused to apply style from 'https://localhost/styles.34c57ab7888ec1573f9c.css' because its MIME type ('text/plain') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
after setting X-Content-Type-Options to nosniff in NGINX. I am building Angular (version 6.0.3) like
"ng build --prod --configuration=production --subresource-integrity"
And the output index.html looks like:
...
<body>
<app-root></app-root>
<script type="text/javascript" src="runtime.a66f828dca56eeb90e02.js" integrity="sha384-v4rB9z5qXuO6U644SALSrNM0l0wvQcniOlRg9Lk3fA3ljnzuAPpETTdOPFjvxVhc" crossorigin="anonymous"></script><script type="text/javascript" src="polyfills.2f4a59095805af02bd79.js" integrity="sha384-ducWBZzn39ArKnKYY70ngb3N7WZhfaMAfPG/AMC1XZcbUcvz0GmT3ymoBXA7KrUt" crossorigin="anonymous"></script><script type="text/javascript" src="main.d28db731850ff9163bb0.js" integrity="sha384-ewBSByvIwZ3px9WtXD5S4GxV8AtRmjlqDY4RS81hPo3D6j1NU3EcB/Hd7zw7KA+4" crossorigin="anonymous"></script></body>
Why is the specified type "text/javascript" instead of "application/javascript"? And is this mismatch causing the error or something else? Then why does Chrome report because its MIME type ('text/plain') is not executable
, detecting a completely different MIME-type than specified?
BTW I am testing this on localhost with self-signed certs, but theoretically this should not be relevant (?)
Upvotes: 1
Views: 5015
Reputation: 7597
When you set X-Content-Type-Options to nosniff you also have to set the allowed types in NGINX. In order to do that you just need to reference their file:
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# ...
}
Upvotes: 2