fix: resolve CORS issue on public status pages and handle UI errors
This commit is contained in:
1 parent
9434cd8929
commit
780ed8147b
2 files changed
+20
-2
No files matched your search
@@ -38,7 +38,7 @@ export const IncidentModal = ({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const open = Boolean(monitorId && date);
|
const open = Boolean(monitorId && date);
|
||||||
|
|
||||||
const { data, isLoading } = useGet<{ incidents: Incident[] }>(
|
const { data, isLoading, error } = useGet<{ incidents: Incident[] }>(
|
||||||
open ? `/status-page/${url}/incidents/${monitorId}?date=${date}` : null,
|
open ? `/status-page/${url}/incidents/${monitorId}?date=${date}` : null,
|
||||||
{},
|
{},
|
||||||
{ revalidateOnFocus: false }
|
{ revalidateOnFocus: false }
|
||||||
@@ -68,6 +68,16 @@ export const IncidentModal = ({
|
|||||||
<Typography mt={SPACING.SM}>
|
<Typography mt={SPACING.SM}>
|
||||||
{t("pages.statusPages.monitorsList.incidents.loading")}
|
{t("pages.statusPages.monitorsList.incidents.loading")}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
) : error ? (
|
||||||
|
<Typography
|
||||||
|
mt={SPACING.SM}
|
||||||
|
color="error"
|
||||||
|
>
|
||||||
|
{t(
|
||||||
|
"pages.statusPages.monitorsList.incidents.errorLoading",
|
||||||
|
"Failed to load incidents."
|
||||||
|
)}
|
||||||
|
</Typography>
|
||||||
) : data?.incidents && data.incidents.length > 0 ? (
|
) : data?.incidents && data.incidents.length > 0 ? (
|
||||||
<Stack
|
<Stack
|
||||||
gap={SPACING.LG}
|
gap={SPACING.LG}
|
||||||
|
|||||||
@@ -16,7 +16,15 @@ export const isPublicStatusPageApiPath = (method: string, path: string): boolean
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!slug || slug === "team" || slug.includes("/")) {
|
if (!slug || slug === "team") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slug.includes("/")) {
|
||||||
|
const parts = slug.split("/");
|
||||||
|
if (parts.length === 3 && parts[1] === "incidents") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user