Let sign-in return to the configured admin origin
Merged
SA
1h ago+124+124+012345678901234567890123456789-4-4-0123456789
Sign-in used to drop a redirect to the admin app (only the web app and API origins were trusted) and landed on the web home. This lets the sign-in flow, and the signed-in redirect in the web proxy, return to exactly the origin in NEXT_PUBLIC_ADMIN_URL.
- New
adminReturnUrlinproxy-routes.ts: exact origin match, no userinfo, no wildcard, no twin domain, no other scheme or port. Used byresolveCallbackUrl(sign-in, sign-up) and by the signed-in redirect inproxy.ts. NEXT_PUBLIC_ADMIN_URLis added to the web app's env schema as optional. Deploy workflows already pass it to the web build. Unset means nothing new is trusted.- Tests cover other hosts, protocol-relative, backslashes, userinfo, subdomain lookalikes, other port and scheme.
Nothing else changes: a redirect that is not a same-origin path, a trusted API origin, or the admin origin still falls back to the web home.
Summary by cubic
Sign-in used to only trust the web app and API origins for redirects, so it always landed on the web home instead of the admin app. This lets sign-in, sign-up, and the signed-in redirect in the web proxy return to exactly the origin in NEXT_PUBLIC_ADMIN_URL.
- Adds
adminReturnUrl, which requires an exact origin match and rejects other hosts, schemes, ports, userinfo, and backslash or protocol-relative tricks. NEXT_PUBLIC_ADMIN_URLis optional and already set by deploy workflows; a malformed or non-http(s) value is ignored, so nothing new is trusted when it's unset.- Redirects that aren't a same-origin path, a trusted API origin, or the admin origin still fall back to the web home.
Summary by CodeRabbit
- New Features
- Sign-in and sign-up redirects can return visitors to a configured admin site, preserving the requested path and query parameters when the destination matches that site.
- Redirects from the proxy can also use a valid destination on the configured admin site.
- Bug Fixes
- Redirects to other origins, malformed or unsupported admin URLs, and destinations containing credentials continue to fall back to the web app. A missing admin URL does not make the admin site a trusted redirect destination.