Mina
Mina

Reputation: 177

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:

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

Upvotes: 3

Views: 3113

Answers (2)

Arkady Elterman
Arkady Elterman

Reputation: 131

Add <base href="/"> in index.html head before linking all css files. (Source: https://github.com/froala/angular-froala/issues/170)

Upvotes: 11

Delowar Hosain
Delowar Hosain

Reputation: 2359

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

Upvotes: 2

Related Questions