React Router: Refused to execute script or styles

问题: When I browse http://localhost:8080/create , its working fine but when browse http://localhost:8080/create/344 or http://localhost:8080/edit/224 I'm getting this error:...

问题:

When I browse http://localhost:8080/create , its working fine but when browse http://localhost:8080/create/344 or http://localhost:8080/edit/224 I'm getting this error:

Refused to apply style from 'http://localhost:8080/edit/dist/main.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

2345:12 GET http://localhost:8080/edit/dist/bundle.js 404 (Not Found) 345:1

Refused to execute script from 'http://localhost:8080/editt/dist/bundle.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

Here is my code:

<BrowserRouter>
    <Switch>
        <Route exact={true} path="/" component={Dashboard} />
        <Route path="/edit/:id" component={EditPost}/>
        <Route path="/create" component={AddPost} />
        <Route component={NotFoundPage}/>
    </Switch>
</BrowserRouter>

check this screenshot please:

enter image description here

here is my webpack config file: https://pastebin.com/d5vx8niQ project file: https://drive.google.com/file/d/1IYcuJTbklXYi53XvIcNRJtb-tLOO4g1j/view?usp=sharing


回答1:

Just use /dist/main.css & /dist/bundle.js instead of dist/main.css & dist/bundle.js in your HTML.

  • 发表于 2018-07-08 10:04
  • 阅读 ( 405 )
  • 分类:sof

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除