React Router - Content Security Policy directive: "default-src 'self'

前端 未结 4 1991
自闭症患者
自闭症患者 2021-01-16 05:25

I\'m testing out react router and I created 2 dummy components. The home path works fine, but when I try to go to the /second path, it gives the following erro

相关标签:
4条回答
  • 2021-01-16 05:49

    Try to add "historyApiFallback: true" in your webpack.config. It worked for me.

    devServer: {
        historyApiFallback: true,
        stats: options.stats,
        hot: true,
        contentBase: './dist',
        watchOptions: {
          ignored: /node_modules/
        }
      }
    
    0 讨论(0)
  • 2021-01-16 05:52

    I solve the error by changing the imported COM's name because I use the WebRTCChane and the WebRTC, this two COM has a similar name, after changing it, I successfully compile.

    0 讨论(0)
  • 2021-01-16 06:12

    I added "--history-api-fallback" to my package.json run scripts

    { "start": "webpack-dev-server --mode development --open --history-api-fallback --hot" }

    0 讨论(0)
  • 2021-01-16 06:13

    You could modify the meta tag in your index.html

    <meta http-equiv="Content-Security-Policy" content="default-src *; 
    connect-src * ws://* wss://*; style-src * 'unsafe-inline' 'unsafe-eval'; media-src * ; 
    img-src * data:; font-src * ; script-src * 'unsafe-inline' 'unsafe-eval';" />`
    
    0 讨论(0)
提交回复
热议问题