Skip to content

fix(gatsby): fetching 404 page with path prefix #34237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

iChenLei
Copy link
Contributor

@iChenLei iChenLei commented Dec 10, 2021

Description

Add e2e test for PR #32528

Closes #32142 and #31504.
Adds the pathPrefix on the doFetch action that checks for 404 page existence. This previously was called without prefix, causing React to break when the resource existed on the root path or a 302 redirect were returned.

Current behaviour

404 page with pathPrefix, broken React rendering (react hydrate), just a static markup( just like only call ReactDOMServer.renderToString(<Page-404 />) )

page-404-no-react-rendering

Expected behaviour

React hydrate success, you can interactive with your gatsby 404 page

page-404

Don't care the console error output, it's just a debug test.

console.error("`${__PATH_PREFIX__}${rawPath}`", `${__PATH_PREFIX__}${rawPath}`);

Related Issues

#31504
#31531
#32142

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Dec 10, 2021
@iChenLei
Copy link
Contributor Author

iChenLei commented Dec 10, 2021

https://dashboard.cypress.io/projects/pzj19c/runs/15628/test-results/67d8f849-6a84-422b-9479-84ba263f9685/video

I don't know why e2e test passed when I didn't add ${__PATH_PREFIX__}${rawPath} to loader.js, but it can reproduce on my loacl machine. cc @wardpeet

@LekoArts LekoArts added topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine) and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Page 404 not rendering react when using pathPrefix and redirect
2 participants