mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-13 19:09:16 +00:00
eliminate duplicate constructurl
This commit is contained in:
@@ -8,7 +8,7 @@ import {
|
|||||||
} from "@zitadel/proto/zitadel/oidc/v2/oidc_service_pb";
|
} from "@zitadel/proto/zitadel/oidc/v2/oidc_service_pb";
|
||||||
import { Session } from "@zitadel/proto/zitadel/session/v2/session_pb";
|
import { Session } from "@zitadel/proto/zitadel/session/v2/session_pb";
|
||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import { constructUrl } from "./service";
|
import { constructUrl } from "./service-url";
|
||||||
import { isSessionValid } from "./session";
|
import { isSessionValid } from "./session";
|
||||||
|
|
||||||
type LoginWithOIDCandSession = {
|
type LoginWithOIDCandSession = {
|
||||||
|
@@ -5,7 +5,7 @@ import { create } from "@zitadel/client";
|
|||||||
import { CreateResponseRequestSchema } from "@zitadel/proto/zitadel/saml/v2/saml_service_pb";
|
import { CreateResponseRequestSchema } from "@zitadel/proto/zitadel/saml/v2/saml_service_pb";
|
||||||
import { Session } from "@zitadel/proto/zitadel/session/v2/session_pb";
|
import { Session } from "@zitadel/proto/zitadel/session/v2/session_pb";
|
||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import { constructUrl } from "./service";
|
import { constructUrl } from "./service-url";
|
||||||
import { isSessionValid } from "./session";
|
import { isSessionValid } from "./session";
|
||||||
|
|
||||||
type LoginWithSAMLandSession = {
|
type LoginWithSAMLandSession = {
|
||||||
|
@@ -4,7 +4,7 @@ import { createServerTransport } from "@zitadel/client/node";
|
|||||||
import { createUserServiceClient } from "@zitadel/client/v2";
|
import { createUserServiceClient } from "@zitadel/client/v2";
|
||||||
import { headers } from "next/headers";
|
import { headers } from "next/headers";
|
||||||
import { getSessionCookieById } from "./cookies";
|
import { getSessionCookieById } from "./cookies";
|
||||||
import { getServiceUrlFromHeaders } from "./service";
|
import { getServiceUrlFromHeaders } from "./service-url";
|
||||||
import { getSession } from "./zitadel";
|
import { getSession } from "./zitadel";
|
||||||
|
|
||||||
const transport = async (serviceUrl: string, token: string) => {
|
const transport = async (serviceUrl: string, token: string) => {
|
||||||
|
@@ -7,7 +7,6 @@ import { SAMLService } from "@zitadel/proto/zitadel/saml/v2/saml_service_pb";
|
|||||||
import { SessionService } from "@zitadel/proto/zitadel/session/v2/session_service_pb";
|
import { SessionService } from "@zitadel/proto/zitadel/session/v2/session_service_pb";
|
||||||
import { SettingsService } from "@zitadel/proto/zitadel/settings/v2/settings_service_pb";
|
import { SettingsService } from "@zitadel/proto/zitadel/settings/v2/settings_service_pb";
|
||||||
import { UserService } from "@zitadel/proto/zitadel/user/v2/user_service_pb";
|
import { UserService } from "@zitadel/proto/zitadel/user/v2/user_service_pb";
|
||||||
import { NextRequest } from "next/server";
|
|
||||||
import { systemAPIToken } from "./api";
|
import { systemAPIToken } from "./api";
|
||||||
|
|
||||||
type ServiceClass =
|
type ServiceClass =
|
||||||
@@ -65,16 +64,3 @@ export async function createServiceForHost<T extends ServiceClass>(
|
|||||||
|
|
||||||
return createClientFor<T>(service)(transport);
|
return createClientFor<T>(service)(transport);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function constructUrl(request: NextRequest, path: string) {
|
|
||||||
const forwardedProto = request.headers.get("x-forwarded-proto")
|
|
||||||
? `${request.headers.get("x-forwarded-proto")}:`
|
|
||||||
: request.nextUrl.protocol;
|
|
||||||
|
|
||||||
const forwardedHost =
|
|
||||||
request.headers.get("x-zitadel-forward-host") ??
|
|
||||||
request.headers.get("x-forwarded-host") ??
|
|
||||||
request.headers.get("host");
|
|
||||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
|
|
||||||
return new URL(`${basePath}${path}`, `${forwardedProto}//${forwardedHost}`);
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user