question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Routes not working in production

See original GitHub issue

Hi, I have really liked this seed project. However when I run the command npm run build everything works fine and I see the complied result in dist folder. I have added couple of new routes, views and components. After the compilation is done. When I try running the files from the dist folder I only see the Home page, when I try navigating to other pages it gives a 404 error.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
zeeshanjan82commented, Jun 7, 2017
0reactions
frostinicommented, Apr 29, 2018

thanks for pointing that out @zeeshanjan82 ! For others that may run into the issue, the https://github.com/bripkens/connect-history-api-fallback does the trick or you can also manually set a catch-all route and redirect to index for vue router to parse. This is how it could be implemented in express:

serving static build through root (*using serve-static npm)

app.use("/", serveStatic ( path.join (__dirname, '/dist') ) )

manual catch-all

app.get('*', function (req, res) {
    res.sendFile(__dirname + '/dist/index.html')
})

PS. for newbies, remember to do a npm run build prior to depoyment to include the latest changes !

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-router does not work in production and surge deployments
In dev mode all things works great but when i switched to the production build there was some routing issues in my react...
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 >
React router page links not working in production : r/reactjs
Hey everyone. So I have a react site where I use react router to link to different pages. It works locally, but when...
Read more >
React Router not Working in Production - DEV Community ‍ ‍
When I put the website live on a server, I'm not able to type the URL in the browser. If I do so,...
Read more >
Why is React Router not working in production? - Quora
React Router is not working in production. ... the routes exists in the code that is running on the browser, but the routes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found