Encountering the error “Because its MIME type (‘text/html’) is not executable, and strict MIME type checking is enabled” can be frustrating, especially for developers working with JavaScript, CSS, or other external resources.
This issue is commonly seen in modern web development, particularly when dealing with Content Security Policies (CSP) and cross-origin resource sharing (CORS) settings.
In this guide, we’ll break down what this error means, why it happens, and how to fix it with actionable solutions.
What Does This Error Mean?

The error “Because its MIME type (‘text/html’) is not executable, and strict MIME type checking is enabled“ occurs when a browser refuses to execute a file because its MIME type doesn’t match the expected format.
This often happens when JavaScript, CSS, or other resources are mistakenly served as instead of their correct MIME type.
MIME Type Explained
MIME (Multipurpose Internet Mail Extensions) types tell browsers what kind of content to expect from a file. For example:
- text/html → HTML document
- application/javascript → JavaScript file
- text/css → CSS stylesheet
- image/gif → GIF image
When a browser requests a file, the server responds with the file and its MIME type. If the MIME type doesn’t match the expected content, strict MIME type checking will block the resource from being executed.
Strict MIME Type Checking
Strict MIME type checking is a security feature in modern browsers that ensures a resource’s MIME type matches its expected type.
If a JavaScript or CSS file is served as text/html
, the browser refuses to execute it, preventing potential security vulnerabilities.
Why Does This Error Occur?
The “Because its MIME type (‘text/html’) is not executable, and strict MIME type checking is enabled” error occurs due to incorrect server configurations, missing MIME type headers, or security restrictions like Content Security Policies (CSP).
Other causes include improperly configured proxies, Content Delivery Networks (CDNs), and mistyped file paths that return 404 Not Found
HTML pages instead of the expected resource. Identifying the root cause will help you apply the correct fix.
Incorrect Server Configuration
Your web server might be serving JavaScript (.js
), CSS (.css
), or other executable files as text/html
instead of their correct MIME type.
Missing or Incorrect MIME Type Headers
If the server doesn’t explicitly set the correct Content-Type
header, the browser defaults to text/html
, leading to this error.
Content Security Policy (CSP) Restrictions
Strict CSP rules might prevent certain file types from loading if they don’t have the right MIME type.
Improperly Configured Proxy or CDN
A reverse proxy or Content Delivery Network (CDN) might be altering the MIME types of files, causing conflicts.
Fetching the Wrong Resource
Sometimes, a missing file (e.g., a mistyped file path) results in the server returning a generic 404 Not Found
HTML page instead of the expected JavaScript or CSS file.
IIS MIME Type Configuration Issue
If you’re running a website on IIS (Internet Information Services), incorrect MIME type settings can lead to this error. Ensure that IIS is configured to serve JavaScript and other static assets correctly.
How to Fix “Because its MIME type (‘text/html’) is not executable, and strict MIME type checking is enabled”

To resolve this issue, ensure your server correctly assigns MIME types to JavaScript, CSS, and other resources. Modify Apache, Nginx, or IIS configurations to explicitly define the correct MIME types.
Additionally, check your Content Security Policy settings and verify that your files are being served with the correct headers.
If you’re working with Vue.js, React, Angular, or SAP UI5, ensure your build and deployment configurations do not serve JavaScript files as text/html
.
For framework-based applications (Vue, React, Angular), verifying build and deployment settings is essentia
Verify Server MIME Type Configuration
Ensure your server correctly sets MIME types for JavaScript and CSS files. Here’s how to fix it for different web servers Because its MIME type (‘text/html’) is not executable, and strict MIME type checking is enabled:
Apache:
Add the following lines to your .htaccess
file:
AddType application/javascript .js
AddType text/css .css
Nginx:
Modify the mime.types
file or nginx.conf
:
types {
text/javascript js;
text/css css;
}
IIS:
For IIS, add the correct MIME types in the web.config file:
<system.webServer>
<staticContent>
<mimeMap fileExtension=".js" mimeType="application/javascript" />
<mimeMap fileExtension=".css" mimeType="text/css" />
</staticContent>
</system.webServer>
Set Correct Content-Type Headers
If you’re serving files dynamically via a backend (e.g., Node.js, PHP, or Python), make sure you set the correct headers.
Node.js (Express Example):
app.get('/script.js', (req, res) => {
res.setHeader('Content-Type', 'application/javascript');
res.sendFile(__dirname + '/script.js');
});
PHP:
header("Content-Type: application/javascript");
Disable Strict MIME Type Checking (Temporary Solution)

In some cases, you may want to Because its MIME type (‘text/html’) is not executable, and strict MIME type checking is enabled temporarily for debugging purposes.
However, this is not recommended for production due to security risks. In Chrome, you can disable strict MIME checking using:
chrome.exe --disable-web-security --user-data-dir="C:/ChromeDevSession"
Check Your Framework-Specific Issues
Vue.js
If you’re facing this issue in Vue.js, ensure that your build and deployment configurations correctly set MIME types for JavaScript files.
React
For React apps, verify that your server isn’t serving JavaScript bundles as text/html
due to misconfigured routes or missing files.
Angular
Angular applications can face this issue when a production build is incorrectly deployed, causing JavaScript files to be served as HTML.
SAP UI5
If you’re working with SAP UI5, ensure your server settings and Content Security Policies allow the correct MIME types.
Conclusion
Fixing the “Because its MIME type (‘text/html’) is not executable, and strict MIME type checking is enabled” error is crucial for ensuring smooth website functionality.
By properly configuring your server, setting correct headers, and debugging issues using DevTools, you can prevent this frustrating error.
Now that you have the solutions, go ahead and apply them to your project! Still stuck? Drop your questions in the comments below.
FAQs
How do I fix a MIME type error?
Ensure your server is setting the correct MIME type for files using appropriate configuration settings.
How do I enable MIME types?
Configure your web server (Apache, Nginx, IIS) to serve the correct MIME types using configuration files.
How do I fix an invalid MIME type?
Check the Content-Type
response header using browser DevTools and update server settings accordingly.
What is the MIME type of text/html?
The MIME type text/html
is used for HTML documents and should not be assigned to JavaScript or CSS files.