Skip to content
  1. LuzineDebug
  2. Web, HTML & CSS
  3. Refused to apply style from 'https://example.com…
Web, HTML & CSS Beginner ≈ 10 min to fix

Fix "Refused to apply style … MIME type ('text/html') is not a supported stylesheet MIME type"

Error message
Refused to apply style from 'https://example.com/css/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
  • 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.
  • Refused to apply style from 'https://example.com/blog/css/app.css' because its MIME type ('text/plain') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
  • The stylesheet https://example.com/css/style.css was not loaded because its MIME type, “text/html”, is not “text/css”.
  • Did not parse stylesheet at 'https://example.com/css/style.css' because non CSS MIME types are not allowed in strict mode.
In short

The browser requested your CSS file but received an HTML page, almost always a 404 page or a SPA home page returned instead of a missing file. Open the CSS URL in a tab: fix the path (often a relative path to make absolute with /) or make the server send the file with Content-Type: text/css.

Be the first to confirm this fix

What this error means

A stylesheet is only applied if the server sends it with the text/css MIME type. When the response comes as text/html, Chrome refuses to interpret it, especially if the server sends X-Content-Type-Options: nosniff, which is standard today. The announced type is almost never the real problem: it reveals that the server did not find the file and replied with an HTML page (404 error, login page, or index.html returned by a single-page app fallback rule). More rarely, the file exists but the server does not know the .css extension.

Common causes

  1. Relative path: href="css/style.css" on the /blog/article page becomes /blog/css/style.css, which does not exist.
  2. File missing from the deployment: dist/ or public/build/ folder not uploaded, build not run, wrong case (Style.css vs style.css on a Linux server).
  3. SPA fallback rule or catch-all route that returns index.html for every URL, including missing static files.
  4. Static folder misconfigured: express.static mounted on the wrong folder or after the * route, or include mime.types missing from the nginx configuration.
  5. Link to an uncompiled file: a <link> pointing to a .scss file or a Tailwind source file instead of the generated CSS.

Step-by-step fix

  1. See what the server really returns

    Open the CSS URL quoted in the error in a new tab, or query it with curl. An HTML page or a 404 code confirms a path or missing-file problem.

    bash
    curl -sI https://example.com/css/style.css | grep -iE "^HTTP|content-type"
  2. Use an absolute path

    Start the path with / so it resolves from the site root, whatever the page. In Laravel, use asset() or @vite.

    xml
    <!-- wrong on /blog/article -->
    <link rel="stylesheet" href="css/style.css">
    <!-- right -->
    <link rel="stylesheet" href="/css/style.css">
  3. Check the file is really deployed

    Run the build and check that the file exists at the expected path on the server, with the right case.

    bash
    npm run build
    ls -la dist/assets/ public/build/assets/ 2>/dev/null
  4. Express: serve static files before the fallback

    Mount express.static on the right folder and before the route that returns index.html. With Express 5, the catch-all route is written /{*splat}.

    javascript
    import express from 'express';
    import path from 'node:path';
    
    const app = express();
    const dist = path.resolve('dist');
    
    app.use(express.static(dist));
    app.get('/{*splat}', (req, res) => res.sendFile(path.join(dist, 'index.html')));
  5. nginx: MIME types and 404 on static files

    Check that mime.types is included and that a missing CSS or JS file returns a real 404 instead of index.html. Test, then reload nginx.

    nginx
    http {
        include /etc/nginx/mime.types;
    
        server {
            root /var/www/app/dist;
    
            location ~* \.(?:css|js|mjs|map)$ {
                try_files $uri =404;
            }
    
            location / {
                try_files $uri $uri/ /index.html;
            }
        }
    }

Did this fix work for you?

Confirm it in one click: it will rise for the next developers stuck on the same error.

Keep it from coming back

  • Let your build tool or framework generate the <link> tags instead of writing them by hand.
  • Configure the server so missing static files return a 404: the error becomes obvious in the Network tab.
  • Name your files in lowercase to avoid surprises between macOS/Windows (case-insensitive) and Linux.

Frequently asked questions

Should I remove the X-Content-Type-Options: nosniff header?

No. It protects against disguised files being executed. The real problem is that the server returns HTML instead of CSS: fix the path or the MIME type.

CSS works on the home page but not on other pages, why?

Your link is relative. On /, css/style.css points to the right place; on /blog/article, it points to /blog/css/style.css. Add a leading /.

What if the announced type is text/plain?

The file is found but the server does not know the extension: add include mime.types (nginx), AddType text/css .css (Apache) or check your host or S3 bucket configuration.

Useful tools for this error

More Web, HTML & CSS errors

All Web, HTML & CSS errors →