Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Oauth redirect #581

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions frontend/src/app/auth/oauth/callback/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
5 changes: 5 additions & 0 deletions tracecat/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."}
Loading