mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 14:47:33 +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 || "";
|
||||
}
|
||||
|
||||
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(
|
||||
(domain) => domain.generated === true,
|
||||
);
|
||||
|
@@ -32,7 +32,7 @@ export async function middleware(request: NextRequest) {
|
||||
instanceUrl = await getInstanceUrl(host);
|
||||
} catch (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,
|
||||
);
|
||||
instanceUrl = process.env.ZITADEL_API_URL;
|
||||
|
Reference in New Issue
Block a user