chec / commercejs-nextjs-demo-store

Commerce demo store built for the Jamstack. Built with Commerce.js, Next.js, and can be one-click deployed to Netlify. Includes product catalog, customer login, categories, variants, cart, checkout, payments (Stripe) order confirmation, and printable receipts.
https://commercejs-demo-store.netlify.app/
BSD 3-Clause "New" or "Revised" License
1.07k stars 206 forks source link

Login callback URL doesn't have route params provided, prevents login from working #153

Closed robbieaverill closed 3 years ago

robbieaverill commented 3 years ago

Expected: Customer should be logged in and be shown customer section Actual: login form shows again

https://nextjs.org/docs/routing/dynamic-routes#caveats

kvisca commented 3 years ago

@robbieaverill The is issue is as outlined below by Guy.

Pages that are statically optimized by Automatic Static Optimization will be hydrated without their route parameters provided, i.e query will be an empty object ({}). After hydration, Next.js will trigger an update to your application to provide the route parameters in the query object.

What we need to do to solve this is to encapsulate the login form and logic into a second component that is dynamic with no SSR. You can find information on how to do that here: https://nextjs.org/docs/advanced-features/dynamic-import#with-no-ssr

jaepass commented 3 years ago

yes this is right, think I did the same for the confirm page. see the Confirm component where had to declare no ssr when importing it in to the Confirm index page

robbieaverill commented 3 years ago

Thanks @kvisca @jaepass and @notrab - PR to fix this at #154, and I've also raised a number of new enhancement issues to refactor and modernise the codebase a little.