Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix: isolate status development and protect cached reads
Richie McIlroy6807174f8700
diff --git a/apps/status/README.md b/apps/status/README.mdindex cdc493e47..b67159b35 100644--- a/apps/status/README.md+++ b/apps/status/README.md@@ -9,6 +9,7 @@ An independent Next.js app for `status.cap.so`. It reuses the current landing pa3. Set a random `CRON_SECRET` of at least 32 bytes on production. Vercel sends it as the cron’s Bearer token. Do not prefix any of these variables with `NEXT_PUBLIC_`.4. Configure the production service URLs below. Deploy on a plan supporting **five-minute cron jobs** (Vercel Pro or higher), then add `status.cap.so` to this project and point its DNS at Vercel. The page starts with honest “no data” states until checks run.5. Verify the first `/api/cron/check` invocation succeeds in the Vercel logs and `/api/status` contains current observations for every configured service. Set an **external dead-man monitor** to alert when `/api/status` has an old `checkedAt` (over 15 minutes), returns non-200, or cannot be reached. This detects a failed scheduler, Redis, or the status deployment itself.+6. Before public launch, configure a Vercel WAF rate limit for `/api/status` (GET and HEAD). Start with 300 requests per minute per IP in log mode, check expected traffic, then enforce with a 429 response. The public API rejects query parameters before accessing Redis, preventing cache-busting URLs from consuming storage requests. The WAF rule protects function usage as well and is configured on the separate status project, not the main site.No production deployment, DNS changes, external monitors, or storage resources are created by this PR.@@ -50,7 +51,7 @@ bun run --cwd apps/status typecheckbun run --cwd apps/status build```-Copy `.env.example` to `.env.local` in this app for local configuration. Use a separate development Redis database. `bun run --cwd apps/status start` serves the production build on port 3002; `dev` uses the same port. Respect the repository’s existing-server rules when starting a local server.+Copy `.env.example` to `.env.local` in this app for local configuration. Use a separate development Redis database. `bun run --cwd apps/status start` serves the production build on port 3003; `bun run --cwd apps/status dev` uses the same port. The status app is excluded from the root development commands, including the Windows wrapper, so it runs only when explicitly started and cannot take the desktop harness's port 3002. Respect the repository’s existing-server rules when starting a local server.## Screenshotsdiff --git a/apps/status/app/api/status/route.ts b/apps/status/app/api/status/route.tsindex 1124daf95..2de30338e 100644--- a/apps/status/app/api/status/route.ts+++ b/apps/status/app/api/status/route.ts@@ -3,7 +3,13 @@ import { getRedis, readState } from "../../../lib/store";export const dynamic = "force-dynamic";-export async function GET() {+export async function GET(request: Request) {+ if (new URL(request.url).search) {+ return Response.json(+ { error: "Query parameters are not supported" },+ { status: 400, headers: { "Cache-Control": "no-store" } },+ );+ }try {return Response.json(publicSnapshot(await readState(getRedis())), {headers: {diff --git a/apps/status/package.json b/apps/status/package.jsonindex 54fdc563c..443c40e40 100644--- a/apps/status/package.json+++ b/apps/status/package.json@@ -3,9 +3,9 @@"version": "1.0.0","private": true,"scripts": {- "dev": "next dev --port 3002",+ "dev": "next dev --port 3003","build": "next build",- "start": "next start --port 3002",+ "start": "next start --port 3003","typecheck": "next typegen && tsc --noEmit","test": "bun test tests"},diff --git a/apps/status/tests/routes.test.ts b/apps/status/tests/routes.test.tsindex a7230101a..d1c77ca9f 100644--- a/apps/status/tests/routes.test.ts+++ b/apps/status/tests/routes.test.ts@@ -8,6 +8,7 @@ import deployment from "../vercel.json";const values = new Map<string, string>();const realFetch = globalThis.fetch;+let storageCommands = 0;const variableNames = ["UPSTASH_REDIS_REST_URL","UPSTASH_REDIS_REST_TOKEN",@@ -23,6 +24,7 @@ let failStorage = false;let stealLease = false;function command(args: string[]) {+ storageCommands++;const [name, key, value] = args;if (name.toUpperCase() === "SET") {if (args.some((arg) => arg.toUpperCase() === "NX") && values.has(key))@@ -60,6 +62,7 @@ const server = Bun.serve({beforeEach(() => {values.clear();+ storageCommands = 0;probeCalls = 0;failStorage = false;stealLease = false;@@ -111,6 +114,23 @@ describe("scheduler → storage → public API", () => {expect(values.size).toBe(0);});+ test("rejects cache-busting queries before accessing storage", async () => {+ for (const query of [+ "?x=one",+ "?x=two",+ "?cache=false×tamp=123",+ "?%78=encoded",+ ]) {+ const response = await readStatus(+ new Request(`https://status.example/api/status${query}`),+ );+ expect(response.status).toBe(400);+ expect(response.headers.get("cache-control")).toBe("no-store");+ }+ expect(storageCommands).toBe(0);+ expect(probeCalls).toBe(0);+ });+test("previews never probe production services", async () => {process.env.VERCEL_ENV = "preview";expect(await (await collect(authorizedRequest())).json()).toEqual({@@ -124,7 +144,9 @@ describe("scheduler → storage → public API", () => {expect(probeCalls).toBe(6);expect(values.has(STATE_KEY)).toBe(true);expect(values.has(LOCK_KEY)).toBe(false);- const response = await readStatus();+ const response = await readStatus(+ new Request("https://status.example/api/status"),+ );const snapshot = await response.json();expect(snapshot.services.every(@@ -188,7 +210,9 @@ describe("scheduler → storage → public API", () => {test("storage outages return unknown data without cached success", async () => {failStorage = true;- const response = await readStatus();+ const response = await readStatus(+ new Request("https://status.example/api/status"),+ );expect(response.status).toBe(503);expect(response.headers.get("cache-control")).toBe("no-store");expect(diff --git a/package.json b/package.jsonindex bc7c64c9a..63c46e9ab 100644--- a/package.json+++ b/package.json@@ -15,10 +15,10 @@"db:generate": "dotenv -e .env -- bun run --filter @cap/database db:generate","db:push": "dotenv -e .env -- bun run --filter @cap/database db:push","db:studio": "dotenv -e .env -- bun run --filter @cap/database db:studio",- "dev": "bun run docker:up && trap 'bun run docker:stop' EXIT && dotenv -e .env -- turbo run dev --filter=!@cap/chrome-extension --env-mode=loose --ui tui",+ "dev": "bun run docker:up && trap 'bun run docker:stop' EXIT && dotenv -e .env -- turbo run dev --filter=!@cap/chrome-extension --filter=!@cap/status --env-mode=loose --ui tui","dev:desktop": "bun run --cwd apps/desktop dev","dev:extension": "bun run docker:up && trap 'bun run docker:stop' EXIT && dotenv -e .env -- turbo run dev --filter=@cap/web --filter=@cap/chrome-extension --env-mode=loose --ui tui",- "dev:manual": "bun run docker:up && trap 'bun run docker:stop' EXIT && dotenv -e .env -- turbo run dev --filter=!@cap/chrome-extension --no-cache --concurrency 1",+ "dev:manual": "bun run docker:up && trap 'bun run docker:stop' EXIT && dotenv -e .env -- turbo run dev --filter=!@cap/chrome-extension --filter=!@cap/status --no-cache --concurrency 1","dev:mobile": "bun run docker:up && trap 'bun run docker:stop' EXIT && CAP_MOBILE_DISABLE_ASSOCIATED_DOMAINS=1 EXPO_PUBLIC_CAP_WEB_URL=${EXPO_PUBLIC_CAP_WEB_URL:-http://localhost:3000} dotenv -e .env -- turbo run dev --filter=@cap/web --filter=@cap/mobile --env-mode=loose --ui tui","dev:mobile:physical": "bun run docker:up && trap 'bun run docker:stop' EXIT && CAP_MOBILE_DEVICE=physical CAP_MOBILE_DISABLE_ASSOCIATED_DOMAINS=1 dotenv -e .env -- turbo run dev --filter=@cap/web --filter=@cap/mobile --env-mode=loose --ui tui","dev:web": "bun run dev --filter=!@cap/desktop --filter=!@cap/mobile",diff --git a/scripts/dev-windows.cmd b/scripts/dev-windows.cmdindex 91bb13191..53b8c8492 100644--- a/scripts/dev-windows.cmd+++ b/scripts/dev-windows.cmd@@ -1,2 +1,2 @@@echo off-start /b cmd /c "bun run docker:up > nul" && timeout /t 5 /nobreak > nul && dotenv -e .env -- turbo run dev --filter=!@cap/chrome-extension --filter=!@cap/mobile --env-mode=loose --ui tui %*+start /b cmd /c "bun run docker:up > nul" && timeout /t 5 /nobreak > nul && dotenv -e .env -- turbo run dev --filter=!@cap/chrome-extension --filter=!@cap/status --filter=!@cap/mobile --env-mode=loose --ui tui %*