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

后端 未结 7 1148
误落风尘
误落风尘 2020-12-17 16:25

I am trying to setup react routing which works when I click on something on my site the route works, however if I open a new tab and copy that url. I get

Ref         


        
相关标签:
7条回答
  • 2020-12-17 16:51

    Your webpack config is malformed. So your devServer is returning the fallback html file instead of the bundle.

    Hence why the script is served with the ('text/html') MIME type.

    devServer: {
        historyApiFallback:{
          index:'/dist/index.html'
        },
      }
    

    You probably meant something like this:

    devServer: {
      historyApiFallback: true
    }
    

    https://webpack.js.org/configuration/dev-server/

    0 讨论(0)
提交回复
热议问题