gatsby: Routes to other pages not working in production only

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.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 33 (15 by maintainers)

Most upvoted comments

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?

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.

I am also facing the same issue when deploying my site to s3 the links are not working. there is no error on console. I am not using pathPrefix in gatsby-config.js. I am just using Link to='/home/test'>test</Link>. Routing is working fine on my local but i dont know why its not working on staging.

Is there a solution for this? I still have the same issue, in 2022

I want to load this page https://js6yw-cyaaa-aaaag-aaa5q-cai.ic0.app/start. When you click on its URL to open, or paste the URL in Chrome directly, it will not open the referenced page but switch to the default https://js6yw-cyaaa-aaaag-aaa5q-cai.ic0.app/. However, this start page has indeed been uploaded. It’s in the public folder; I can see this page is uploaded when deploying files to the Internet Computer’s canister; and this page can be visited by clicking Article on the top menu bar, then Start. @ninegua, who is from the team that built the Internet Computer (IC), confirmed that this issue has nothing to do with IC deployment. So this is the same old Gatsby issue that you guys have been discussing since 2017.

I don’t use pathPrefix in my gatsby-config.js. This solution by @KyleAMathews doesn’t solve my problem.

I’m on Gatsby 4.6.2.

@drydenwilliams Hey there! Since the original issue is closed, could you do us a favor and start a new issue for this? Thank you!

@msal4 I suggest opening a new issue to get more eyeballs on it. Seems like their work in January cleared up this issue for this one specific circumstance.