@@ -43,6 +43,9 @@ docker exec -it "$(docker ps -qf name=dokploy.1)" bash -c "pnpm run reset-passwo
4343 The compose only references ` ${...} ` , so an empty Environment tab means empty values — e.g. a
4444 blank ` POSTGRES_PASSWORD ` makes Postgres refuse to start. Verify:
4545 - ` BETTER_AUTH_URL=https://auth.monashcoding.com `
46+ - ` TRUSTED_ORIGINS=http://localhost:3000,http://localhost:3001 ` if both local app ports
47+ are in use. Origins are exact, so only add ` 127.0.0.1 ` variants if developers actually
48+ browse to those addresses.
4649 - ` POSTGRES_PASSWORD ` is ** URL/shell-safe** (letters+digits only — no ` $ @ : / # ` ).
4750 - No value is truncated when pasted (watch long ones like ` GOOGLE_CLIENT_ID ` , which must end
4851 in ` .apps.googleusercontent.com ` ).
@@ -77,6 +80,36 @@ curl -s -X POST https://auth.monashcoding.com/api/auth/sign-in/social \
7780```
7881Paste that returned ` url ` into a browser to walk the real Google consent → callback flow.
7982
83+ ### Verify localhost OAuth after this cookie-policy change
84+
85+ The auth service deliberately issues Better Auth cookies with `HttpOnly; Secure;
86+ SameSite=None`. This is required because local MAC apps create the OAuth state cookie and
87+ later use the session through credentialed cross-site requests to the production auth
88+ origin. Better Auth's CSRF and trusted-origin validation remain enabled; do not replace the
89+ explicit ` TRUSTED_ORIGINS ` allowlist with ` * ` .
90+
91+ After deploying:
92+
93+ 1 . Confirm the Dokploy Environment tab contains every ** actual** local origin, comma-separated
94+ (normally ` http://localhost:3000,http://localhost:3001 ` ), then redeploy after any change.
95+ 2 . Use a Chrome Guest profile (or clear cookies for ` auth.monashcoding.com ` ), open the local
96+ app, enable ** Preserve log** in DevTools Network, and start Google sign-in once.
97+ 3 . Inspect ` POST /api/auth/sign-in/social ` . It must return the exact requesting origin in
98+ ` Access-Control-Allow-Origin ` , ` Access-Control-Allow-Credentials: true ` , and a redacted
99+ state cookie equivalent to:
100+ ` __Secure-better-auth.state=<value>; Domain=.monashcoding.com; Path=/; HttpOnly; Secure; SameSite=None ` .
101+ 4 . Confirm that cookie is stored under ` https://auth.monashcoding.com ` before leaving for
102+ Google, then confirm the callback succeeds without ` state_mismatch ` and returns to the
103+ allowlisted local callback URL.
104+ 5 . Repeat from both local ports that the apps actually use, then smoke-test the production
105+ MAC Study and Job Board origins.
106+
107+ ` SameSite=None ` cannot override a browser setting that blocks third-party cookies entirely.
108+ If DevTools says the cookie was blocked for that reason, the durable next step is a small
109+ allowlisted page on ` auth.monashcoding.com ` that starts OAuth while the auth domain is the
110+ top-level site. Do not work around that policy by disabling Better Auth's state-cookie,
111+ CSRF, or origin checks.
112+
80113---
81114
82115## Troubleshooting: 404 / hanging requests
0 commit comments