mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-22 07:07:41 +00:00
use host header in middleware instead of nexturl.host
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { headers } from "next/headers";
|
||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import { getInstanceUrl } from "./lib/api";
|
import { getInstanceUrl } from "./lib/api";
|
||||||
|
|
||||||
@@ -19,10 +20,16 @@ export async function middleware(request: NextRequest) {
|
|||||||
// ) {
|
// ) {
|
||||||
// return NextResponse.next();
|
// return NextResponse.next();
|
||||||
// }
|
// }
|
||||||
|
const _headers = await headers();
|
||||||
|
const _host = _headers.get("host");
|
||||||
|
|
||||||
|
console.log("host", _host);
|
||||||
|
|
||||||
|
const host = _host || request.nextUrl.host;
|
||||||
|
|
||||||
let instanceUrl;
|
let instanceUrl;
|
||||||
try {
|
try {
|
||||||
instanceUrl = await getInstanceUrl(request.nextUrl.host);
|
instanceUrl = await getInstanceUrl(host);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(
|
console.error(
|
||||||
"Could not get instance url, fallback to ZITADEL_API_URL",
|
"Could not get instance url, fallback to ZITADEL_API_URL",
|
||||||
|
Reference in New Issue
Block a user