angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

Open mohibrahimm opened this issue 8 years ago • 48 comments

This is the issue I'm getting

Angular CLI: 1.7.2 Node: 8.9.4 OS: win32 x64 Angular: 5.2.5 ... animations, common, compiler, compiler-cli, core, forms ... http, language-service, platform-browser ... platform-browser-dynamic, router

@angular/cli: 1.7.2 @angular-devkit/build-optimizer: 0.3.2 @angular-devkit/core: 0.3.2 @angular-devkit/schematics: 0.3.2 @ngtools/json-schema: 1.2.0 @ngtools/webpack: 1.10.1 @schematics/angular: 0.3.2 @schematics/package-update: 0.3.2 typescript: 2.5.3 webpack: 3.11.0

Deploy files to to server Service Worker caches all the files Deploy updated files to server Get this error on refresh after deploying updated files: Refused to execute script from Refused to apply style from 'https://martmax.co/martmax/styles.90e231a43b112dde0a8e.bundle.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled. Refused to execute script from 'https://martmax.co/martmax/inline.42eab311bb328d4389bc.bundle.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled. martmax.co/:1 Refused to execute script from 'https://martmax.co/martmax/polyfills.a6e3c1aba633d4169f73.bundle.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled. martmax.co/:1 Refused to execute script from 'https://martmax.co/martmax/scripts.a5ebe8c46eb086e27504.bundle.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled. martmax.co/:1 Refused to execute script from 'https://martmax.co/martmax/main.dd14f2660d7784d60e49.bundle.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled. martmax.co/:1 Refused to apply style from 'https://martmax.co/martmax/styles.90e231a43b112dde0a8e.bundle.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Doing a hard refresh (CMD + SHIFT + R) skips the service worker cache and loads the newly deployed files without any issues. And then doing a regular refresh causes the error to come back.

My sw.js is not being cached and have nginx setup.

Deploying an update and refreshing pulls files from service worker, but they have the incorrect content- image image

image

My initial guess is that it's an issue with index.html , but asking if you guys have any other guesses.

@comewalk @jesperronn @mprobst @filipesilva @Brocco @texel

mohibrahimm avatar Apr 13 '18 16:04 mohibrahimm

Regarding what @blacksonic said. I have the same problem - I mean application looking for files *.bundle.js although those files are generated without suffix bundle. If I will add manually that suffix to each file then everything works fine. Is there anyway to fix it?

pklejnowski avatar Jun 09 '18 10:06 pklejnowski

@filipesilva is there any reason why you have removed bundle suffix? Those files ain't "bundled" anymore?

pklejnowski avatar Jun 09 '18 10:06 pklejnowski

Same problem here, MIME type ('text/html') is not executable, and strict MIME type checking is enabled. I am working on a Node Project.

pkdsite avatar Jun 13 '18 07:06 pkdsite

I had same issue with Angular 6, I updated my base tag in index.html as follows and issue was resolved.

<head>
    <meta charset="utf-8">
    <base href="/">
    <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>

manojdcoder avatar Jun 22 '18 05:06 manojdcoder

Yeah i had the same issue. I have applied type='text/html' in link tag and issue was resolved.

Dharmendert20 avatar Jul 03 '18 08:07 Dharmendert20

I am seeing this issue in a project where my angular-cli generated app is in a subdir of my "main" project dir, and I try to use ng serve --serve-path <subdir>.

I reproduced this by generating a new project and running ng serve --serve-path . from the freshly generated project.

The output of my ng --version is:

Angular CLI: 6.0.8 Node: 10.6.0 OS: win32 x64 Angular: 6.0.7 ... animations, common, compiler, compiler-cli, core, forms ... http, language-service, platform-browser ... platform-browser-dynamic, router

Package Version

@angular-devkit/architect 0.6.8 @angular-devkit/build-angular 0.6.8 @angular-devkit/build-optimizer 0.6.8 @angular-devkit/core 0.6.8 @angular-devkit/schematics 0.6.8 @angular/cli 6.0.8 @ngtools/webpack 6.0.8 @schematics/angular 0.6.8 @schematics/update 0.6.8 rxjs 6.2.1 typescript 2.7.2 webpack 4.8.3

I may very well be misunderstanding the usage and intent of the --serve-path flag in this use case, so my apologies in advance.

janhurst avatar Jul 10 '18 05:07 janhurst

Same error Refused to apply style from 'http://localhost:3000/styles.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled. I even tried <base href="/"> but it didn't worked. Does someone have any idea how to make it work?

knrt10 avatar Aug 22 '18 11:08 knrt10

Use "text/html" in link tag

It will work.

On Wed, Aug 22, 2018, 4:42 PM Kautilya Tripathi [email protected] wrote:

Same error Refused to apply style from 'http://localhost:3000/styles.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled. I even tried but it didn't worked. Does someone have any idea how to make it work?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/10325#issuecomment-414997167, or mute the thread https://github.com/notifications/unsubscribe-auth/AdiZVNUW82UqIJFaJu_bXEuhhhoJsnEpks5uTTy3gaJpZM4TTvYC .

Dharmendert20 avatar Aug 22 '18 11:08 Dharmendert20

n my case, my dev site set mode is production and I used command: bin/magento setup:static-content:deploy it just deploy static content for en_US and not deploy for en_AU so all static of AU site is missed. I have to deploy using command: bin/magento s:s:d en_AU then all works as normal

When you switch from developer mode to production mode it will deploy static content for all languages. but when you use command bin/magento setup:static-content:deploy it just deploy static for en_US

I wrote post describe more detail here: https://mrvts.wordpress.com/2018/08/29/magento-2-break-layout-with-message-refused-to-apply-style-because-its-mime-type-text-html-is-not-a-supported-stylesheet-mime-type/

vtransy avatar Aug 29 '18 12:08 vtransy

I'm running into same issue. Any help , plz- https://stackoverflow.com/questions/52323908/refused-to-execute-script-runtime-js-because-mime-type-is-not-executable

shauryac avatar Sep 14 '18 03:09 shauryac

Hi there,

Please add text/html in link tag

Regards Dharmender

On Fri, Sep 14, 2018, 9:24 AM shauryac [email protected] wrote:

I'm running into same issue. Any help , plz-

https://stackoverflow.com/questions/52323908/refused-to-execute-script-runtime-js-because-mime-type-is-not-executable

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/10325#issuecomment-421223191, or mute the thread https://github.com/notifications/unsubscribe-auth/AdiZVHmB353uMT8RHRpl0yzNiK5poMYjks5uayhagaJpZM4TTvYC .

Dharmendert20 avatar Sep 14 '18 05:09 Dharmendert20

@Dharmendert20 thanks for reply. Did you look at generated index.html (stackoverflow link)? It has the following link tag: <link rel="icon" type="image/x-icon" href="favicon.ico"> The exact error when open file in browser from Intellij: "Refused to execute script from 'http://localhost:63342/runtime.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled."

I don't think it makes sense to change the type for . I believe the issue is with

Owner


Other Repo Issues