fix fcn request

This commit is contained in:
Max Peintner
2025-01-29 13:25:45 +01:00
parent f117044c53
commit 4687db084f
3 changed files with 11 additions and 7 deletions

View File

@@ -1,4 +1,3 @@
ZITADEL_API_URL=http://localhost:22222
EMAIL_VERIFICATION=true
DEBUG=true
NEXT_PUBLIC_BASE_PATH="/"
DEBUG=true

View File

@@ -80,7 +80,7 @@ export default async function Page(props: { searchParams: Promise<any> }) {
});
}
const userResponse = await getUserByID(userId);
const userResponse = await getUserByID({ serviceUrl, userId });
if (userResponse) {
user = userResponse.user;
if (user?.type.case === "human") {

View File

@@ -34,8 +34,12 @@ export async function createServiceForHost<T extends ServiceClass>(
token = process.env.ZITADEL_SERVICE_USER_TOKEN;
}
if (!serviceUrl || !token) {
throw new Error("No instance url or token found");
if (!serviceUrl) {
throw new Error("No instance url found");
}
if (!token) {
throw new Error("No token found");
}
const transport = createServerTransport(token, {
@@ -48,9 +52,10 @@ export async function createServiceForHost<T extends ServiceClass>(
export function getServiceUrlFromHeaders(headers: ReadonlyHeaders): string {
let instanceUrl: string = process.env.ZITADEL_API_URL;
const forwardedHost = headers.get("x-zitadel-forward-host");
// use the forwarded host if available (multitenant), otherwise fall back to the host of the deployment itself
if (headers.get("x-zitadel-forward-host")) {
instanceUrl = headers.get("x-zitadel-forward-host") as string;
if (forwardedHost) {
instanceUrl = forwardedHost;
instanceUrl = instanceUrl.startsWith("https://")
? instanceUrl
: `https://${instanceUrl}`;