Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Router - CSS Styling BREAKS using params? - Status 304 Not Modified?

Please help. I have everything working fine, signup page works fine and so does the sign in page. However, when I go to a url route /user/3 for instance, it breaks my custom CSS styling page put in the public directory of my react/redux app. The My stylesheet is no longer being read at all. Only the bootstrap styles.

When I look at the network tab in chrome dev tools, on my other routes stylesheet is getting sent with status 200, but when I try to access a route with a slash, i.e. /user/4, stylesheet gets sent as 304 Not Modified...

ReactDOM.render(
  <Router history={browserHistory}>
    <Route path="/" component={App}>
      <IndexRoute component={App}></IndexRoute>
      <Route path="/user/:user" component={UserDashboard}></Route>
      <Route path="/signup" component={Signup} />
      <Route path="/signin" component={Signin} />
    </Route>
  </Router>
  ,
  document.getElementById('root')
);
like image 608
user7024499 Avatar asked Oct 25 '25 09:10

user7024499


2 Answers

I have the same problem and I solve it changing the link to my css file.

It was:

<link rel="stylesheet" href="./css/materialize.min.css">

And the solution are: (remove first dot, and all runs OK)

<link rel="stylesheet" href="/css/materialize.min.css">

Maybe you problem was other... but I have the same problem that you.

like image 87
Javi Campaña Avatar answered Oct 26 '25 23:10

Javi Campaña


304 is because of the browser cache. You can clear the cache through the settings of the browser or use Ctrl+F5(windows)/ Command + R(MacOS) to force a refresh. Then try it again.

like image 32
Jason Xu Avatar answered Oct 26 '25 23:10

Jason Xu