https://github.com/mojotech/next-props-wiping-bug-demo
Demonstrating a bug with NextJS wiping props
https://github.com/mojotech/next-props-wiping-bug-demo
Last synced: 12 months ago
JSON representation
Demonstrating a bug with NextJS wiping props
- Host: GitHub
- URL: https://github.com/mojotech/next-props-wiping-bug-demo
- Owner: mojotech
- Created: 2022-12-07T15:45:38.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-07T15:46:31.000Z (over 3 years ago)
- Last Synced: 2025-06-19T05:11:40.528Z (about 1 year ago)
- Language: TypeScript
- Size: 65.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This repo exists to demonstrate a bug.
`nmp run dev` and browse to:
http://localhost:3000/en-us/z/a.html
You will see that the getStaticProps runs on the server and produces the correct props on initial render:
```
{ product : {aye: 'bar'} }
```
But then Next makes another XHR request to `en-us/z/a.html.json`. The server 308-redirects this to `/en-us/z/a.html`, which returns a response
in html format.
The client side of Next attempts to parse this response as JSON and winds up with `{}`, which then becomes the Page's new props. In effect, all props are wiped out.
This bug goes away if any of the following things change:
* rename middleware.ts (which does nothing) to another filename
* change trailingSlash in the config to false.
* request http://localhost:3000/en-us/z/a/ instead of using the .html suffix.
Unfortunately, our app requires all of these things. So we have to deal with this Next bug.