Skip to content

Open-source status page, incident response and uptime monitoring

fix: status page password search query (#1551)

Maximilian Kaskebc0781334a22
diff --git a/apps/status-page/src/app/(status-page)/[domain]/layout.tsx b/apps/status-page/src/app/(status-page)/[domain]/layout.tsx
index 7c92cffa0..12c20ceea 100644
--- a/apps/status-page/src/app/(status-page)/[domain]/layout.tsx
+++ b/apps/status-page/src/app/(status-page)/[domain]/layout.tsx
@@ -1,4 +1,5 @@
import { defaultMetadata, ogMetadata, twitterMetadata } from "@/app/metadata";
+import { PasswordWrapper } from "@/components/password-wrapper";
import {
FloatingButton,
StatusPageProvider,
@@ -78,6 +79,7 @@ export default async function Layout({
richColors
expand
/>
+ <PasswordWrapper />
</StatusPageProvider>
</ThemeProvider>
</HydrateClient>
diff --git a/apps/status-page/src/components/password-wrapper.tsx b/apps/status-page/src/components/password-wrapper.tsx
new file mode 100644
index 000000000..528c0e28b
--- /dev/null
+++ b/apps/status-page/src/components/password-wrapper.tsx
@@ -0,0 +1,23 @@
+"use client";
+
+import { createProtectedCookieKey } from "@/lib/protected";
+import { useParams } from "next/navigation";
+import { parseAsString, useQueryState } from "nuqs";
+import { useEffect } from "react";
+
+export function PasswordWrapper({ children }: { children?: React.ReactNode }) {
+ const [password, setPassword] = useQueryState("pw", parseAsString);
+ const { domain } = useParams<{ domain: string }>();
+
+ useEffect(() => {
+ if (password) {
+ const key = createProtectedCookieKey(domain);
+ document.cookie = `${key}=${password}; path=/; expires=${new Date(
+ Date.now() + 1000 * 60 * 60 * 24 * 30,
+ ).toUTCString()}`;
+ setPassword(null);
+ }
+ }, [password, domain, setPassword]);
+
+ return children;
+}
diff --git a/apps/status-page/src/middleware.ts b/apps/status-page/src/middleware.ts
index 1c22e61f0..06a450b05 100644
--- a/apps/status-page/src/middleware.ts
+++ b/apps/status-page/src/middleware.ts
@@ -55,8 +55,9 @@ export default async function middleware(req: NextRequest) {
if (_page?.passwordProtected) {
const protectedCookie = cookies.get(createProtectedCookieKey(_page.slug));
- const password = protectedCookie ? protectedCookie.value : undefined;
- console.log({ protectedCookie, password });
+ const cookiePassword = protectedCookie ? protectedCookie.value : undefined;
+ const queryPassword = url.searchParams.get("pw");
+ const password = queryPassword || cookiePassword;
if (password !== _page.password && !url.pathname.endsWith("/protected")) {
const { pathname, origin } = req.nextUrl;
diff --git a/packages/tinybird/pipes/endpoint__http_metrics_latency_1d_multi__v1.pipe b/packages/tinybird/pipes/endpoint__http_metrics_latency_1d_multi__v1.pipe
index f74f0ea54..7adac3fb6 100644
--- a/packages/tinybird/pipes/endpoint__http_metrics_latency_1d_multi__v1.pipe
+++ b/packages/tinybird/pipes/endpoint__http_metrics_latency_1d_multi__v1.pipe
@@ -19,6 +19,6 @@ SQL >
WHERE
monitorId IN {{ Array(monitorIds, 'String', '1,666') }}
GROUP BY h, monitorId
- ORDER BY h DESC
+ ORDER BY h ASC