fix: use FRONTEND_URL for redirects behind proxy
Build and Deploy / test-backend (push) Successful in 55s
Build and Deploy / lint-frontend (push) Successful in 12s
Build and Deploy / build-backend (push) Successful in 3s
Build and Deploy / build-frontend (push) Successful in 29s
Build and Deploy / deploy (push) Successful in 5s

This commit is contained in:
Ivan Rezchikov
2026-09-18 01:50:22 +03:00
parent 7d46042102
commit c84b18faa8
3 changed files with 9 additions and 8 deletions
+4 -6
View File
@@ -1,16 +1,14 @@
import { NextResponse } from "next/server";
import { cookies, headers as fetchHeaders } from "next/headers";
import { cookies } from "next/headers";
import { generateCodeVerifier, generateCodeChallenge, generateState } from "@/lib/pkce";
const FLOW_TTL = 60 * 10;
const origin = () => new URL(process.env.FRONTEND_URL ?? "http://localhost:3000").origin;
export async function GET() {
if ((await cookies()).get("session")) {
const headers = await fetchHeaders();
const protocol = headers.get("x-forwarded-proto") ?? "http";
const host = headers.get("host");
const origin = host ? `${protocol}://${host}` : "http://localhost:3000";
return NextResponse.redirect(new URL("/", origin));
return NextResponse.redirect(new URL("/", origin()));
}
const verifier = generateCodeVerifier();