mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-13 17:17:59 +00:00
error handling
This commit is contained in:
@@ -9,7 +9,15 @@ export async function getInstanceUrl(host: string): Promise<string> {
|
|||||||
return process.env.ZITADEL_API_URL || "";
|
return process.env.ZITADEL_API_URL || "";
|
||||||
}
|
}
|
||||||
|
|
||||||
const instance = await getInstanceByHost(host);
|
const instance = await getInstanceByHost(host).catch((error) => {
|
||||||
|
console.error(`Could not get instance by host ${host}`, error);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!instance) {
|
||||||
|
throw new Error("No instance found");
|
||||||
|
}
|
||||||
|
|
||||||
const generatedDomain = instance.domains.find(
|
const generatedDomain = instance.domains.find(
|
||||||
(domain) => domain.generated === true,
|
(domain) => domain.generated === true,
|
||||||
);
|
);
|
||||||
|
@@ -32,7 +32,7 @@ export async function middleware(request: NextRequest) {
|
|||||||
instanceUrl = await getInstanceUrl(host);
|
instanceUrl = await getInstanceUrl(host);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(
|
console.error(
|
||||||
"Could not get instance url, fallback to ZITADEL_API_URL",
|
`[Middleware]: Could not get instance url of ${host}, fallback to ZITADEL_API_URL ${process.env.ZITADEL_API_URL}`,
|
||||||
error,
|
error,
|
||||||
);
|
);
|
||||||
instanceUrl = process.env.ZITADEL_API_URL;
|
instanceUrl = process.env.ZITADEL_API_URL;
|
||||||
|
Reference in New Issue
Block a user