Commiting to switch to a different orm
This commit is contained in:
@@ -2,21 +2,21 @@ import { NextRequest } from "next/server";
|
||||
import { handlers } from "@/lib/auth";
|
||||
|
||||
const reqWithTrustedOrigin = (req: NextRequest): NextRequest => {
|
||||
const proto = req.headers.get('x-forwarded-proto')
|
||||
const host = req.headers.get('x-forwarded-host')
|
||||
const proto = req.headers.get('x-forwarded-proto');
|
||||
const host = req.headers.get('x-forwarded-host');
|
||||
if (!proto || !host) {
|
||||
console.warn("Missing x-forwarded-proto or x-forwarded-host headers.")
|
||||
return req
|
||||
console.warn("Missing x-forwarded-proto or x-forwarded-host headers.");
|
||||
return req;
|
||||
}
|
||||
const envOrigin = `${proto}://${host}`
|
||||
const { href, origin } = req.nextUrl
|
||||
return new NextRequest(href.replace(origin, envOrigin), req)
|
||||
}
|
||||
const envOrigin = `${proto}://${host}`;
|
||||
const { href, origin } = req.nextUrl;
|
||||
return new NextRequest(href.replace(origin, envOrigin), req);
|
||||
};
|
||||
|
||||
export const GET = (req: NextRequest) => {
|
||||
return handlers.GET(reqWithTrustedOrigin(req))
|
||||
}
|
||||
export const GET = (req: NextRequest): Promise<Response> => {
|
||||
return handlers.GET(reqWithTrustedOrigin(req));
|
||||
};
|
||||
|
||||
export const POST = (req: NextRequest) => {
|
||||
return handlers.POST(reqWithTrustedOrigin(req))
|
||||
}
|
||||
export const POST = (req: NextRequest): Promise<Response> => {
|
||||
return handlers.POST(reqWithTrustedOrigin(req));
|
||||
};
|
||||
Reference in New Issue
Block a user