mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-19 20:24:32 +02:00
Use HTTP/1.1 with nginx for chunked transfers
This commit is contained in:
@@ -1,6 +1,30 @@
|
||||
import { buildUrl } from "@/lib/userSS";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
|
||||
const getDomain = (request: NextRequest) => {
|
||||
// use env variable if set
|
||||
if (process.env.BASE_URL) {
|
||||
return process.env.BASE_URL;
|
||||
}
|
||||
|
||||
// next, try and build domain from headers
|
||||
const requestedHost = request.headers.get('X-Forwarded-Host');
|
||||
const requestedPort = request.headers.get('X-Forwarded-Port');
|
||||
const requestedProto = request.headers.get('X-Forwarded-Proto');
|
||||
if (requestedHost) {
|
||||
const url = request.nextUrl.clone();
|
||||
url.host = requestedHost;
|
||||
url.protocol = requestedProto || url.protocol;
|
||||
url.port = requestedPort || url.port;
|
||||
return url.origin;
|
||||
}
|
||||
|
||||
// finally just use whatever is in the request
|
||||
return request.nextUrl.origin
|
||||
}
|
||||
|
||||
|
||||
export const GET = async (request: NextRequest) => {
|
||||
// Wrapper around the FastAPI endpoint /auth/google/callback,
|
||||
// which adds back a redirect to the main app.
|
||||
@@ -11,10 +35,14 @@ export const GET = async (request: NextRequest) => {
|
||||
const setCookieHeader = response.headers.get("set-cookie");
|
||||
|
||||
if (!setCookieHeader) {
|
||||
return NextResponse.redirect(new URL("/auth/error", request.url));
|
||||
return NextResponse.redirect(
|
||||
new URL("/auth/error", getDomain(request))
|
||||
);
|
||||
}
|
||||
|
||||
const redirectResponse = NextResponse.redirect(new URL("/", request.url));
|
||||
const redirectResponse = NextResponse.redirect(
|
||||
new URL("/", getDomain(request))
|
||||
);
|
||||
redirectResponse.headers.set("set-cookie", setCookieHeader);
|
||||
return redirectResponse;
|
||||
};
|
||||
|
Reference in New Issue
Block a user