I am trying to deploy a React JS front-end build to WebSphere. The latter communicates with a Spring Boot back-end on a remote server. The build deployment (on a subdirectory of the WebSphere URL) is successful and most of the routes are accessible, however, I am facing a navigation issue as follows:
Log Out redirects to 1.1.1.1:port which is expected behavior. However, going back in the browser button redirects to 1.1.1.1:port which renders a "File not Found" exception.
Please note that I tried the following methods:
I am expecting the browser back to not allow re-direction to the root directory of WebSphere (outside the project directory). Or an enhanced deployment method, should the current be not optimal.
This is happening because the various routes configured in React is unknown to WAS. It doesn't know the internal routes of the React application. So if any internal route is requested by the browser, it should be let for the react application javascript code to decide.
If you have an HTTP Server which runs in front of WAS, then the redirection rules can be added there.
Else you can add the rules in the web.xml
file which takes to the index.hml
file when there is an error.
<error-page>
<error-code>404</error-code>
<location>/</location>
</error-page>
assuming you have index.html
at the root of this web application.