frandiox / vitedge

Edge-side rendering and fullstack Vite framework
https://vitedge.js.org
MIT License
730 stars 31 forks source link

Loading Root Page via SSR ends up in SyntaxError: Unexpected end of JSON input #33

Closed hrgui closed 3 years ago

hrgui commented 3 years ago

https://pokedex-vitedge.hrgui.workers.dev/ leads to error 1101

In wrangler dev:

Uncaught
SyntaxError: Unexpected end of JSON input
Uncaught (in promise)
SyntaxError: Unexpected end of JSON input
Uncaught (in response)
SyntaxError: Unexpected end of JSON input

While https://pokedex-vitedge.hrgui.workers.dev/pokemon/1 works, then navigating home works also. However, refreshing the page there doesn't work.

See https://github.com/hrgui/pokedex-vitedge for repo

  1. yarn && yarn build in root
  2. npm install && wrangler dev in workers-site
frandiox commented 3 years ago

This was because home route was trying to request props but there was no handler for that. It should now skip it if there is no handler 👍 (0.13.2)

frandiox commented 3 years ago

@hrgui Apart from that, there are some dependency issues in your project: I think you need to remove all the dependencies and devDependencies from workers-site/package.json (it will grab them from the parent directory), and then move react-helmet-async, react-router-config and react-router-dom to dependencies from devDependencies in the root package.json. It's also missing @types/react-router-dom dev dependency. Tell me if that works.