Skip to content

Fix signin/signout process for reliability - #79

Merged
rbouteiller merged 10 commits into
usetrmnl:mainfrom
scruffy359:fix-signin-signout
Jun 28, 2026
Merged

Fix signin/signout process for reliability#79
rbouteiller merged 10 commits into
usetrmnl:mainfrom
scruffy359:fix-signin-signout

Conversation

@scruffy359

Copy link
Copy Markdown
Contributor
  • fix infinite redirect between setup/signin when AUTH_ENABLED=true. add missing await connection().
  • use browser navigation instead of push/refresh as refresh will use cached useState. fixes after "Sign Out" returning to Sign In page with "Signing in..." state still active.
  • fix better-auth warning about not setting baseURL

Validated by running under Docker container.
Set AUTH_ENABLED=true
/setup -> /sign-in
/sign-in -> /
click "sign out" -> /sign-in with "Sign In" text.

- upgrade PNPM support to latest version (11.5.2)
- fixes build warning
  [WARN] The "pnpm" field in package.json is no longer read by pnpm. The following keys were ignored: "pnpm.onlyBuiltDependencies". See https://pnpm.io/settings for the new home of each setting.
- add package.json engine settings to ensure NODE and PNPM versions are consistent between local dev and docker.
- add .nvmrc in case developer is using NVM.
- add .node-version file.
- lock down pnpm version in docker.
…after Sign Out.

- fix infinite redirect between setup/signin when AUTH_ENABLED=true. add missing `await connection()`.
- use browser navigation instead of push/refresh as refresh will use cached useState.
…after Sign Out.

- fix infinite redirect between setup/signin when AUTH_ENABLED=true. add missing `await connection()`.
- use browser navigation instead of push/refresh as refresh will use cached useState.
…after Sign Out.

- fix infinite redirect between setup/signin when AUTH_ENABLED=true. add missing `await connection()`.
- use browser navigation instead of push/refresh as refresh will use cached useState.
@rbouteiller

rbouteiller commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the fix. I checked the router.refresh() concern and I agree with the direction.

One thing I think we should adjust before merging: baseURL is now sourced from NEXT_PUBLIC_BASE_URL, but this repo already documents and passes BETTER_AUTH_URL for Better Auth (docker-compose.yml sets BETTER_AUTH_URL=${BETTER_AUTH_URL:-http://localhost:3000}). Deployments that only set BETTER_AUTH_URL would now fall back to http://localhost:3000.

Minor polish: for sign-out, I’d use window.location.replace("/sign-in") instead of assigning href, so the back button does not return to a stale authenticated route. href/assign is fine for sign-in.

- resolve the app base URL at runtime via getAppBaseUrl()
  (BETTER_AUTH_URL > Vercel URL > localhost) and pass it to better-auth as
  origin; drop build-time-only NEXT_PUBLIC_BASE_URL (all consumers are
  server-side) — the browser renderer now targets the loopback origin
- apply the sign-in navigation fix to sign-up; use location.replace() on
  sign-out so Back can't reach an authenticated page
- type the sign-up submit handler as React.SubmitEvent (FormEvent is deprecated)

BREAKING CHANGE: NEXT_PUBLIC_BASE_URL is no longer read. Set BETTER_AUTH_URL
or rely on Vercel auto-detection.
React.FormEvent is deprecated in @types/react. Use React.SubmitEvent for
form onSubmit handlers and React.SyntheticEvent where a handler is shared
between a form submit and a button click.
@rbouteiller
rbouteiller merged commit fe966c6 into usetrmnl:main Jun 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants