Nested routes rendering with React-Router and Express is not working

Francois Huyghe
Aug 8, 2017 · 1 min read

Simple paths like /current are rendering fine on refresh, but as soon as a second layer is reached, /current/all for example, the console sends the following error:

Uncaught SyntaxError: Unexpected token <

The problem is caused by the browser using relative urls. The solution is to specify the base URL so that all path are defined relative to /. Adding <basehref="/"> in the head fixes the problem.

Solution on StackOverflow

Francois Huyghe

Written by

Enthusiasm enthusiast. Partner at 13milliseconds

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade