Refreshing then hitting the back button causes 404 [Update: Development-mode only]
See original GitHub issueUpdate
From comments below: If you use gatsby build
/ gatsby serve
, the bug doesn’t happen, apparently. So, it affects development only.
Description
If you refresh a page, then click on the back button, you get 404 instead of getting to the page you were on.
Steps to reproduce
Links
- Reproduction on Codesandbox: https://codesandbox.io/s/github/hossameldeen/Gatsby-site
- Source code link: https://github.com/hossameldeen/Gatsby-site
Steps
- Clone the repo, run
gatsby develop
, and openhttp://localhost:8000
(or just open codesandbox link above) - You should see a link
click to go to /another-page
- Click on the link.
- You should now see a page with some text.
- Click on refresh button in the browser.
- Click on the back button in the browser.
Expected result
Go back to the homepage http://localhost:8000
and show its contents (the link)
Actual result
Getting 404
Environment
System:
OS: Windows 10 10.0.19041
CPU: (12) x64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
Binaries:
Node: 12.19.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.14.8 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.19041.423.0), Chromium (88.0.705.63)
npmPackages:
gatsby: ^2.32.3 => 2.32.3
More info
- Same issue when using
navigate
instead ofLink
. - Seems to be the same issue as #7261
- Credits of finding the issue and providing a reproduction to @mostafa-zaied
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:20 (1 by maintainers)
Top Results From Across the Web
Back button not working and error 404 on refresh
I have 2 questions: 1) When i press a back button on browser or on mobile, it is not going back instead it...
Read more >Error 404: 4 Ways to Fix It - Hostinger
Error 404 is a response code, meaning the server could not locate the requested content. Check this article to learn 4 steps to...
Read more >3 Known Issues and Workarounds - Oracle Help Center
After a page flow completes in the WebLogic Server Administration Console, it forwards to a different page, typically a table. Pressing the browser...
Read more >Error 404 not found - What does it mean & how to fix it! - IONOS
This can be checked quite easily by clicking on the 'Refresh' button in your browser or also by pressing the F5 button.
Read more >404 when hitting refresh in a router component - Vue Forum
Whenever I access a branch component from the router via a button on the page, it works fine and the url changes to...
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 FreeTop 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
Top GitHub Comments
@hossameldeen Yes, I did notice that it happens only in development mode. But it’s quite weird as I’m unable to reproduce it today at all.
Has this issue been investigated? It still seems to be present in 4.13.0.
It’s true that the impact is lower because it only causes a 404 in development, but I believe it is still relevant as it causes a good bit of frustration in development, especially in trying to develop features that involve route changes.