Skip to content

Refused to apply style because its MIME type ('application/json') is not a supported stylesheet MIME type, and strict MIME checking is enabled. #580

Closed
@gauravshah27

Description

@gauravshah27

npm ls http-proxy-middleware

Please verify that you've followed these steps

[x] - I've updated to latest http-proxy-middleware.

Describe the bug

I am using a combination of create-react-app + http-proxy-middleware for my application.

I am seeing the following issue

Refused to apply style from 'https://<app>.<domain>/static/css/main.a9d14d20.chunk.css' because its MIME type ('application/json') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

I was not seeing this issue with [email protected]. So I am not sure how to go about fixing this.

To Reproduce

Step-by-step reproduction instructions

1. take any create-react-app application that uses http-proxy-middleware
2. update http-proxy-middleware to 1.3.1
3. open the browser and find an unstyled app and the above mentioned error will be present on the browser console

Expected behavior

It should load the stylesheet from the main chunk and application should appear with the correct styles loaded.

http-proxy-middleware configuration

const {createProxyMiddleware} = require('http-proxy-middleware');

module.exports = function (app) {
  app.use(
    ['/api', '/login', '/loginSuccess', '/logout'],
    createProxyMiddleware({
      target: 'http://localhost:8080',
      changeOrigin: true,
      autoRewrite: true
    })
  );
};

Server (please complete the following information):

  • OS: Windows
  • NodeJS version: 14.16.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions