Routing not working when running app with Production Config
See original GitHub issueOpening a new window with specifc page is redirecting back to index route. This behavior is only happening when running the application with npm run start
. Routes are working properly when running the application with num run dev
.
childWindow.loadURL(`file://${__dirname}/app.html#/${containerId}/second`);
Routes are setup as below.
<App>
<Switch>
<Route path="/signup" component={SignUpContainer} />
<Route path="/home" component={HomeContainer} />
<Route path="/:containerId/second" component={SecondContainer} />
<Route path="/" component={SplashContainer} />
</Switch>
</App>
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Angular routing not working after running ng build at deployment
I'm running Angular 12.2. 0 and have setup routes on localhost. I'm just navigating between two pages at the moment to see how...
Read more >Handling React Routing in Production - Pluralsight
This guide shows how to solve a page not found error you've in a React app that uses React Router or the HTML5...
Read more >Router tutorial: tour of heroes - Angular
In this tutorial, you build upon a basic router configuration to explore features such as child routes, route parameters, lazy load NgModules, guard...
Read more >Deployment | Create React App
npm run build creates a build directory with a production build of ... This may not work for client-side routers which expect the...
Read more >Set up staging environments - Azure App Service
Learn how to deploy apps to a non-production slot and autoswap into ... Some configuration elements follow the content across a swap (not...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
My understanding was the same regarding HashRouter. This is my entrypoint code
And this is my Switch-Route setup
Warning I get:
Nothing worked. I looked at like 10 different answers for this. Eventually figured this out through trial and error, works in both dev and prod:
__dirname
works only in dev.I wrote an SO answer with more details: https://stackoverflow.com/a/63441289/1884363