mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
fix: docker callback url
This commit is contained in:
parent
9ad5c1f289
commit
9a0b65a3ab
@ -1,4 +1,22 @@
|
||||
import { handlers } from "@/auth";
|
||||
import { NextRequest } from "next/server";
|
||||
|
||||
// Referring to the auth.ts we just created
|
||||
export const { GET, POST } = handlers;
|
||||
const reqWithTrustedOrigin = (req: NextRequest): NextRequest => {
|
||||
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;
|
||||
}
|
||||
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 POST = (req: NextRequest) => {
|
||||
return handlers.POST(reqWithTrustedOrigin(req));
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user