VersifiXion
VersifiXion

Reputation: 2282

Path issue that makes a CSS file not read (React App)

I have a file named custom.css which override materialize.css,

It's imported in public/index.html with this line :

<link rel="stylesheet" href="custom.css" />

On a route like /account, it works fine, in the browser I can see the http://localhost:3000/custom.css loaded,

But on a route like /user/:username, the CSS file becomes http://localhost:3000/user/custom.css so it doesn't work,

I did my project with create-react-app, and I'm not using a bundler (maybe there's one with the boilerplate),

I don't even know where to start to resolve this issue,

Upvotes: 0

Views: 77

Answers (1)

Dmitry Sobolevsky
Dmitry Sobolevsky

Reputation: 1191

I suppose you use such import path:

<link rel="stylesheet" type="text/css" href="custom.css">

You have to replace path with :

href="/custom.css"

Upvotes: 2

Related Questions