Skip to content

Commit

Permalink
use host header in middleware instead of nexturl.host
Browse files Browse the repository at this point in the history
  • Loading branch information
peintnermax committed Jan 16, 2025
1 parent 5a1853a commit 827f38a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion apps/login/src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { headers } from "next/headers";
import { NextRequest, NextResponse } from "next/server";
import { getInstanceUrl } from "./lib/api";

Expand All @@ -19,10 +20,16 @@ export async function middleware(request: NextRequest) {
// ) {
// return NextResponse.next();
// }
const _headers = await headers();
const _host = _headers.get("host");

console.log("host", _host);

const host = _host || request.nextUrl.host;

let instanceUrl;
try {
instanceUrl = await getInstanceUrl(request.nextUrl.host);
instanceUrl = await getInstanceUrl(host);
} catch (error) {
console.error(
"Could not get instance url, fallback to ZITADEL_API_URL",
Expand Down

0 comments on commit 827f38a

Please sign in to comment.