Openstatus www.openstatus.dev

fix: status page password search query (#1551)

* fix: support pw as search query

* fix: tb pipe

* chore: password wrapper

* fix: build

authored by

Maximilian Kaske and committed by
GitHub
bc078133 58f20d30

+29 -3
+2
apps/status-page/src/app/(status-page)/[domain]/layout.tsx
··· 1 1 import { defaultMetadata, ogMetadata, twitterMetadata } from "@/app/metadata"; 2 + import { PasswordWrapper } from "@/components/password-wrapper"; 2 3 import { 3 4 FloatingButton, 4 5 StatusPageProvider, ··· 78 79 richColors 79 80 expand 80 81 /> 82 + <PasswordWrapper /> 81 83 </StatusPageProvider> 82 84 </ThemeProvider> 83 85 </HydrateClient>
+23
apps/status-page/src/components/password-wrapper.tsx
··· 1 + "use client"; 2 + 3 + import { createProtectedCookieKey } from "@/lib/protected"; 4 + import { useParams } from "next/navigation"; 5 + import { parseAsString, useQueryState } from "nuqs"; 6 + import { useEffect } from "react"; 7 + 8 + export function PasswordWrapper({ children }: { children?: React.ReactNode }) { 9 + const [password, setPassword] = useQueryState("pw", parseAsString); 10 + const { domain } = useParams<{ domain: string }>(); 11 + 12 + useEffect(() => { 13 + if (password) { 14 + const key = createProtectedCookieKey(domain); 15 + document.cookie = `${key}=${password}; path=/; expires=${new Date( 16 + Date.now() + 1000 * 60 * 60 * 24 * 30, 17 + ).toUTCString()}`; 18 + setPassword(null); 19 + } 20 + }, [password, domain, setPassword]); 21 + 22 + return children; 23 + }
+3 -2
apps/status-page/src/middleware.ts
··· 55 55 56 56 if (_page?.passwordProtected) { 57 57 const protectedCookie = cookies.get(createProtectedCookieKey(_page.slug)); 58 - const password = protectedCookie ? protectedCookie.value : undefined; 59 - console.log({ protectedCookie, password }); 58 + const cookiePassword = protectedCookie ? protectedCookie.value : undefined; 59 + const queryPassword = url.searchParams.get("pw"); 60 + const password = queryPassword || cookiePassword; 60 61 61 62 if (password !== _page.password && !url.pathname.endsWith("/protected")) { 62 63 const { pathname, origin } = req.nextUrl;
+1 -1
packages/tinybird/pipes/endpoint__http_metrics_latency_1d_multi__v1.pipe
··· 19 19 WHERE 20 20 monitorId IN {{ Array(monitorIds, 'String', '1,666') }} 21 21 GROUP BY h, monitorId 22 - ORDER BY h DESC 22 + ORDER BY h ASC 23 23 24 24