react-redux-jwt-auth-example icon indicating copy to clipboard operation
react-redux-jwt-auth-example copied to clipboard

Cannot GET /protected on Refresh or manual URL entry

Open bradder555 opened this issue 8 years ago • 3 comments

Thanks for putting this example together!! this has been a massive help!!

There's an issue with redux-router, when use use a link node to navigate, there's no issues, but if you attempt to enter the url localhost:3000/protected or hit refresh you get "Cannot GET /protected".

I guess this issue could be merged with "Rewrite using redux-simple-router" as i guess react-router-redux is the optimal approach?

Is there a quick fix in the meantime?

I'm a bit of a noob but if no one minds I could try to write a react-router-redux fork?

bradder555 avatar Mar 16 '16 07:03 bradder555

this is an issue with your hosting provider. React-router is a frontend router, not a backend router. You are trying to access the endpoint /protected when it doesn't exist because the backend router doesnt know where that points to.

What you need to do is set up your hosting provider to point ALL routes to index.html so that React-router can handle the rest.

bearcott avatar Mar 26 '16 15:03 bearcott

but when i want to refresh and instead of getting token from localstorage calls user api it fails

snippet componentWillMount() { this.props.fetchUser(); this.checkAuth();

} it calls container render but doesnt render the component

shreychaturvedi123 avatar Sep 08 '16 07:09 shreychaturvedi123

I'm having an issue with ALL child routes behind an nginx proxy.

Here is my simple nginx conf file:

server {

listen 80;

server_name localhost;

location / { try_files $uri /index.html; }

}

The redirect happens, sending the request to /, but the route is utterly lost, it's as though the user was visiting the route page for the first time. Spent all day trying different solutions, but I'm really struggling with react-router right now.

Running the webpack-dev-server, it works fine, but under nginx, for some reason it's just not working. Any help I could get for configuration would be really appreciated.

mikepc avatar Dec 20 '16 17:12 mikepc