Skip to content Skip to sidebar Skip to footer

React-router Issue When Refreshing Urls With Ssl Enabled

Currently I'm experiencing problems using react-router's BrowserHistory with an nginx proxy to forward requests. I've read the following answer: React-router urls don't work when r

Solution 1:

I had a similar issue like yours and my team spent a lot of time looking at nginx and react-router, which was quite similar to your setup.

I also had the following error:

Uncaught SyntaxError: Unexpected token < error

In the end I found a solution, thas was in fact on my index.html server file.

I was using relative paths for my bundle

<linkhref="styles.css"rel="stylesheet" /><scriptsrc="bundle.js"></script>

And after routing, let's say you try to access your/path/subdomain, it would try to get the bundle.js and the styles.css files at your/path/subdomain/styles.css and your/path/subdomain/bundle.js, but they were at the root of my project.

So my solution was just to use

<linkhref="/styles.css"rel="stylesheet" /><scriptsrc="/bundle.js"></script>

And this fixed the issue. Hope this helps you.

Post a Comment for "React-router Issue When Refreshing Urls With Ssl Enabled"