diff --git a/frontend/src/app/auth/oauth/callback/route.ts b/frontend/src/app/auth/oauth/callback/route.ts index f9d95123a..03fe72a66 100644 --- a/frontend/src/app/auth/oauth/callback/route.ts +++ b/frontend/src/app/auth/oauth/callback/route.ts @@ -14,15 +14,18 @@ export const GET = async (request: NextRequest) => { const response = await fetch(url.toString()) const setCookieHeader = response.headers.get("set-cookie") + // Get redirect + const resp = await fetch(buildUrl("/info")) + const { public_app_url } = await resp.json() + console.log("Public app URL", public_app_url) + if (!setCookieHeader) { console.error("No set-cookie header found in response") - return NextResponse.redirect(new URL("/auth/error", getDomain(request))) + return NextResponse.redirect(new URL("/auth/error", public_app_url)) } console.log("Redirecting to /") - const redirectResponse = NextResponse.redirect( - new URL("/", getDomain(request)) - ) + const redirectResponse = NextResponse.redirect(new URL("/", public_app_url)) redirectResponse.headers.set("set-cookie", setCookieHeader) return redirectResponse } diff --git a/tracecat/api/app.py b/tracecat/api/app.py index e27cbd2b9..533e9e862 100644 --- a/tracecat/api/app.py +++ b/tracecat/api/app.py @@ -363,6 +363,11 @@ def root() -> dict[str, str]: return {"message": "Hello world. I am the API."} +@app.get("/info", include_in_schema=False) +def info() -> dict[str, str]: + return {"public_app_url": config.TRACECAT__PUBLIC_APP_URL} + + @app.get("/health", tags=["public"]) def check_health() -> dict[str, str]: return {"message": "Hello world. I am the API. This is the health endpoint."}