Refused to execute script from ‘‘ because its MIME type (‘text/html‘) is not executable, and strict

The error is reported as follows:

 

Refused to execute script from 'http://localhost:8080/style.js?v=1.1' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

There are many situations that cause this error, such as server configuration errors, caching issues, code errors, application deployment issues, etc.

This article is about a problem that occurs when the front-end project is running.

The reason is that I set the public path of static resources in vue.config.js:

So, here’s the key point. All images, js, etc. under public are static resources, so when using them, you must also add the fourth line of the figure to configure /admin/. For example, there is a style.js file in my public directory. :

Then, you also need to add /admin/ when citing in index.html, such as:

 

In this way, style.js can be accessed normally. Although it does not seem to be in the /admin/ directory, we have already configured it in the first picture above, so we must add ./admin/

Otherwise, an error will be reported:

 

Guess you like

Origin blog.csdn.net/qq_68155756/article/details/132424499