Skip to content

Commit 9df2803

Browse files
committed
🐛 fix(auth): use PORTLESS_URL as redirect origin behind the dev proxy
- Auth routes rebuilt redirects from request.url, which behind the portless proxy is the internal localhost:PORT, breaking the OAuth callback with ERR_SSL_PROTOCOL_ERROR. - Use PORTLESS_URL when present; unset in production, so behavior is unchanged.
1 parent 6962c64 commit 9df2803

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

‎src/app/api/auth/github/route.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import { createServerSupabase } from "@/lib/supabase-server";
33
import { isLocalSupabase } from "@/lib/sign-in";
44

55
export async function GET(request: Request) {
6-
const { searchParams, origin } = new URL(request.url);
6+
const url = new URL(request.url);
7+
const { searchParams } = url;
8+
// Atrás do proxy dev do portless, request.url é o localhost:PORT interno.
9+
// PORTLESS_URL é a URL pública https da worktree; em produção não existe.
10+
const origin = (process.env.PORTLESS_URL ?? url.origin).replace(/\/$/, "");
711
const redirectPath = searchParams.get("redirect") ?? "/";
812

913
// Local dev has no GitHub OAuth provider configured — use the dev-login.

‎src/app/auth/callback/route.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ import { provisionDeveloperOnLogin } from "@/lib/auth-provision";
77
export const maxDuration = 60;
88

99
export async function GET(request: Request) {
10-
const { searchParams, origin } = new URL(request.url);
10+
const url = new URL(request.url);
11+
const { searchParams } = url;
12+
// Atrás do proxy dev do portless, request.url é o localhost:PORT interno, então
13+
// os redirects cairiam em https://localhost:PORT (SSL error). PORTLESS_URL é a
14+
// URL pública https desta worktree; em produção não existe → usa o origin real.
15+
const origin = (process.env.PORTLESS_URL ?? url.origin).replace(/\/$/, "");
1116
const code = searchParams.get("code");
1217

1318
if (!code) {

0 commit comments

Comments
 (0)