Problem:
npm run dev
(aka vite dev
) login works as expected
npm run build && npm run preview
login is broken/weird
production deploy login is weird
expected:
scenario: login on homepage GIVEN not logged in WHEN visit homepage WHEN do login WHEN refresh page (a bug, which requires to refresh) THEN avatar img and sign-out link are visible
scenario: logout on homepage GIVEN logged in WHEN visit homepage WHEN do logout WHEN refresh page (a bug, which requires to refresh) THEN sign-in link is visible
scenario: login on protected page GIVEN logged in WHEN visit protected page WHEN do login WHEN refresh page (a bug, which requires to refresh) WHEN visit homepage THEN avatar img and sign-out link are visible
actual:
FAIL: scenario: login on homepage FAIL: scenario: login on homepage SUCCESS: scenario: login on homepage
solution:
delete src/routes/+page.ts
// since there's no dynamic data here, we can prerender
// it so that it gets served as a static asset in production
export const prerender = true;
with login stuff, this home page is no longer a static asset!
(still have this refresh bug, where clicking login/logout does not reload the page)