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 to other pages not working in production only

See original GitHub issue

None of my links from my index route (“/”) are working in production. They all reload the index page but the URL changes to reflect that the page has been navigated to.

I.e. if I click a button to take me to my blog page, the url will change to “www.mysite.com/blog” but the home page just reloads.

I have tried using <Button> with href, and Link via gatsby-link. Neither of which seem to make a difference.

The weird part is that external links placed in the navbar within the index.js file in the Layouts folder work fine.

I haven’t made any changes to the site for over a month, when it was working completely fine. Everything works as intended in development. And there are no errors in dev OR production.

Any idea as to how I might solve this? I need to fix this ASAP. Any help is appreciated! Thanks.

Issue Analytics

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

github_iconTop GitHub Comments

7reactions
rshah03commented, Dec 5, 2017

FIxed. Removed pathPrefix from my gatsby-config.js file and everything is working again. Thanks @KyleAMathews! I think the #2551 nails it.

Alternatively, I could build with the --prefix-paths flag if I wanted to keep that variable.

Is there a way to resolve #2551?

5reactions
KyleAMathewscommented, Dec 5, 2017

Played around with @Swizec’s site and found that building locally with a pathPrefix in the gatsby-config.js is what was breaking things. Commented that out and things worked as expected.

Not sure when or where this started happening. Found it by adding console.log to find-page.js and seeing that pathPrefix was being passed in.

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-router does not work in production and surge deployments
Next question is : I created a 404 page to show up when user tries to move to broken links.It works fine in...
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 ‍ ‍
I have been told I need to add backend with nodejs and more specifically Express backend to the project so I can direct...
Read more >
Deploying React (Router) app to the subfolder on server
If you ever had to deploy React Router app to the subfolder on the server, you know what the problem is. Routes will...
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