3

I changed the web application deployment context path from / to /foo in web.xml, and react-router-component (not react-router) stopped working, giving the following error

Uncaught Error: React-router-component: No route matched! Did you define a NotFound route?

Why react-router-component doesn't detected the context path, and where I need to configure it? I preferably want it to adjust at arbitrary path the application originates from, but hard coding it is also fine.

I read react-router-component documentation, but it didn't mention anything about the application context root.

Tuomas Toivonen
  • 21,690
  • 47
  • 129
  • 225

1 Answers1

0

To get the application context into react-router you could pass configuration to the React app from the Java controller. In Java use HttpServletRequest.getContextPath() to get the context path, and pass this value to the React app.

frevib
  • 446
  • 3
  • 14