DEV Community

Discussion on: Fixing the "cannot GET /URL" error on refresh with React Router (or how client side routers work)

Collapse
 
leoelicos profile image
Leo Wong

Hey I just wanted to say thank you so much for this post, it fixed a bug that nobody on my bootcamp course could fix - by adding a catch-all, I was getting an error after returning from Stripe checkout,

Cannot GET /success

, but after adding the Express catch-all as you suggested:

app.get('/*', (req, res) => {
  res.sendFile(path.join(__dirname, '../client/build/index.html'), (err) => err && res.status(500).send(err));
});
Enter fullscreen mode Exit fullscreen mode

…it worked

Collapse
 
sushant0808 profile image
sushant0808

Can you please share how exactly did you solve this error. I put this in my node application but still didn't work for me. Should I make changes to my frontend react app in the router or any other changes that you made that worked for you. Please help me with this one

Collapse
 
leoelicos profile image
Leo Wong

Only the backend... What's your repo?