fix oidc callback behind reverse proxy
This commit is contained in:
26
proxy.test.ts
Normal file
26
proxy.test.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { NextRequest } from "next/server";
|
||||
import { buildPublicRequestUrl } from "./proxy";
|
||||
|
||||
describe("public request URL", () => {
|
||||
test("uses NEXTAUTH_URL for OIDC callback URLs behind Docker reverse proxies", () => {
|
||||
const request = new NextRequest("http://0.0.0.0:8019/logs?range=7d");
|
||||
|
||||
expect(
|
||||
buildPublicRequestUrl(request, {
|
||||
NEXTAUTH_URL: "https://analytics.example.com",
|
||||
}).href
|
||||
).toBe("https://analytics.example.com/logs?range=7d");
|
||||
});
|
||||
|
||||
test("falls back to forwarded proxy headers when no public URL is configured", () => {
|
||||
const request = new NextRequest("http://0.0.0.0:8019/", {
|
||||
headers: {
|
||||
"x-forwarded-host": "analytics.example.com",
|
||||
"x-forwarded-proto": "https",
|
||||
},
|
||||
});
|
||||
|
||||
expect(buildPublicRequestUrl(request).href).toBe("https://analytics.example.com/");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user