Merge pull request #2603 from Fizza-Mukhtar/fix/prevent-dashboard-domain-conflict-2595

fix: prevent resource from being created with dashboard's domain to avoid redirect loop
This commit is contained in:
Owen Schwartz
2026-03-07 21:15:53 -08:00
committed by GitHub
3 changed files with 29 additions and 1 deletions

View File

@@ -223,6 +223,20 @@ async function createHttpResource(
); );
} }
// Prevent creating resource with same domain as dashboard
const dashboardUrl = config.getRawConfig().app.dashboard_url;
if (dashboardUrl) {
const dashboardHost = new URL(dashboardUrl).hostname;
if (fullDomain === dashboardHost) {
return next(
createHttpError(
HttpCode.CONFLICT,
"Resource domain cannot be the same as the dashboard domain"
)
);
}
}
if (build != "oss") { if (build != "oss") {
const existingLoginPages = await db const existingLoginPages = await db
.select() .select()

View File

@@ -353,6 +353,20 @@ async function updateHttpResource(
); );
} }
// Prevent updating resource with same domain as dashboard
const dashboardUrl = config.getRawConfig().app.dashboard_url;
if (dashboardUrl) {
const dashboardHost = new URL(dashboardUrl).hostname;
if (fullDomain === dashboardHost) {
return next(
createHttpError(
HttpCode.CONFLICT,
"Resource domain cannot be the same as the dashboard domain"
)
);
}
}
if (build != "oss") { if (build != "oss") {
const existingLoginPages = await db const existingLoginPages = await db
.select() .select()

View File

@@ -559,7 +559,7 @@ export default function Page() {
toast({ toast({
variant: "destructive", variant: "destructive",
title: t("resourceErrorCreate"), title: t("resourceErrorCreate"),
description: t("resourceErrorCreateMessageDescription") description: formatAxiosError(e, t("resourceErrorCreateMessageDescription"))
}); });
} }