gatsby icon indicating copy to clipboard operation
gatsby copied to clipboard

Page 404 not rendering react when using pathPrefix and redirect

Open ariadne-github opened this issue 3 years ago β€’ 14 comments

Description

This resumes https://github.com/gatsbyjs/gatsby/issues/31504. When a pathPrefix is used and the hosting is configured to redirect from the root domain to the pathPrefix (perfectly reasonable behaviour I think), triyng to load a non-existing page breaks React .

Steps to reproduce

Reproduction was provided in said issue and in related discussion https://github.com/gatsbyjs/gatsby/discussions/31531.

Expected result

The 404 page should be visible and interactive.

Actual result

The 404 page is loaded but React breaks with "Error: page resources for /xxx not found. Not rendering React.", and the page is not interactive (js is broken).

Investigation

I've debugged the issue carefully, and I've traced down the root cause: this line: https://github.com/gatsbyjs/gatsby/blob/2eb57c7a9dfeb64c351e7154849652e235767e1b/packages/gatsby/cache-dir/loader.js#L526 tries to check a resource existence (comment says "check if html file exist using HEAD request: if it does we should navigate to it instead of showing 404"). The error is that the rawPath it's using, is stripped from the pathPrefix. As I can see, this is used because the internal db of fetched resources is normalized, and anywhere else this function is used: https://github.com/gatsbyjs/gatsby/blob/2eb57c7a9dfeb64c351e7154849652e235767e1b/packages/gatsby/cache-dir/loader.js#L27 which adds back the pathprefix. But there the check is done without the pathPrefix, so it calls the incorrect url. This is not usually a problem because it would normally catch another non-existing url, so the result is the same, but with the described hosting behaviour, anything called on the root is redirected on the pathPrefix (with a 302), so this check fails, incorrectly triggering an error.

ariadne-github avatar Jun 28 '21 08:06 ariadne-github

Hiya!

This issue has gone quiet. Spooky quiet. πŸ‘»

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! πŸ’ͺπŸ’œ

github-actions[bot] avatar Sep 03 '21 00:09 github-actions[bot]

No stale

ariadne-github avatar Sep 03 '21 08:09 ariadne-github

Hiya!

This issue has gone quiet. Spooky quiet. πŸ‘»

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! πŸ’ͺπŸ’œ

github-actions[bot] avatar Sep 24 '21 00:09 github-actions[bot]

Not stale

ariadne-github avatar Sep 24 '21 07:09 ariadne-github

Hiya!

This issue has gone quiet. Spooky quiet. πŸ‘»

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! πŸ’ͺπŸ’œ

github-actions[bot] avatar Oct 14 '21 12:10 github-actions[bot]

Not stale

ariadne-github avatar Oct 14 '21 12:10 ariadne-github

Hiya!

This issue has gone quiet. Spooky quiet. πŸ‘»

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! πŸ’ͺπŸ’œ

github-actions[bot] avatar Nov 04 '21 00:11 github-actions[bot]

Is this issue open for work??

SaiRev0 avatar Oct 08 '22 19:10 SaiRev0

Hi,

tis is genuine issue, please help!!!

ankurparihar avatar Jan 17 '23 10:01 ankurparihar

Hello is anyone working on this right now ?

EyaChebbi avatar Mar 22 '23 14:03 EyaChebbi

I want to work on this is this open

aniruddhapw avatar Apr 03 '23 07:04 aniruddhapw

Hi, Can I get assigned to this role? I would love to contribute.

HarshSingh21 avatar Aug 12 '23 16:08 HarshSingh21

Hello? Anybody still alive at Netlify? This is a real, obvious and straightforward bug and a community fix was provided already 2 years ago....

nkuehn avatar Nov 09 '23 13:11 nkuehn

I would like to work on this issue. Can you please assign it to me?

PATILYASHH avatar Jul 20 '24 06:07 PATILYASHH