gatsby: [v2] Gatsby attempts to reload a page infinitely if the canonical path doesn't match window.location.pathname
This is mainly a problem when the hosting rewrites uppercase URLs as lowercase, and would also occur e.g. if an external link points to a page on a Gatsby site with different casing. To test locally, after running gatsby build and before gatsby serve, copy a page folder to another location (e.g. cp -r public/about public/about-test).
Analysis so far: replacing window.location.pathname with window.page.path in production-app.js (around lines 85) prevents the A page wasn't found for... warning displaying in the console, and loader.getPage(window.page.path) returns true:

(In the future I’ll also perform checks to make sure it still uses window.location.pathname if the canonical path points to the offline app shell, otherwise it would just render a blank page without no-cache=1.)
However, the RouteHandler element’s props.location still use the actual window’s location, and these props are used to determine which page to actually load. I believe they get passed to PageRenderer which then checks if the pageResources exist, and this check fails due to the actual pathname for which Gatsby doesn’t have resources. Thus we have the infinite reload, where &no-cache=1 keeps getting added to the URL: (while testing I returned null before this happens to make things easier, but normally that line wouldn’t exist so it would keep reloading)

So what we need to do is set change the RouteHandler’s props.location.pathname to match the canonical path, to allow Gatsby to find the resources. This is what I’m currently stuck on, I’ll just copy my last commend from #7355 over here
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18 (18 by maintainers)
All tests are passing! PR incoming
/cc @dfmarulanda @ssmith-wombatweb
Tests (now 68)
Nearly finished manual testing (after fixing a few problems it picked up) - all is looking good, so I should be able to create the PR soon!