From 26d459d8602ffbec801089a94339a59e3a612f37 Mon Sep 17 00:00:00 2001 From: "exe.dev user" Date: Wed, 14 Oct 2026 22:12:22 +0000 Subject: [PATCH] fix: serve project deep links through the SPA --- packages/api/src/static-app.ts | 4 ++-- packages/api/test/static-routing.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/api/src/static-app.ts b/packages/api/src/static-app.ts index b7ab0ec3..35b78285 100644 --- a/packages/api/src/static-app.ts +++ b/packages/api/src/static-app.ts @@ -1,9 +1,9 @@ import type { Env } from "./types"; export const STATIC_CSP = "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; base-uri 'none'; frame-ancestors 'none'; form-action 'self'"; -const pages = new Set(["/", "/jobs", "/jobs/new", "/job-runs", "/settings", "/settings/integrations", "/settings/api-keys", "/settings/authorized-clients", "/settings/password", "/auth/login", "/auth/signup", "/auth/password-reset", "/auth/verify", "/auth/verify/request", "/authorize", "/device"]); +const pages = new Set(["/", "/jobs", "/jobs/new", "/projects", "/projects/new", "/job-runs", "/settings", "/settings/integrations", "/settings/api-keys", "/settings/authorized-clients", "/settings/password", "/auth/login", "/auth/signup", "/auth/password-reset", "/auth/verify", "/auth/verify/request", "/authorize", "/device"]); export function isStaticPage(path: string) { - return pages.has(path) || /^\/jobs\/[^/]+(?:\/(?:edit|settings))?$/.test(path) || /^\/job-runs\/[^/]+$/.test(path); + return pages.has(path) || /^\/jobs\/[^/]+(?:\/(?:edit|settings))?$/.test(path) || /^\/projects\/[^/]+$/.test(path) || /^\/job-runs\/[^/]+$/.test(path); } export function isStaticAsset(path: string) { return /^\/assets\/[A-Za-z0-9_.-]+$/.test(path) || path === "/styles.css"; diff --git a/packages/api/test/static-routing.test.ts b/packages/api/test/static-routing.test.ts index 2ff05ba0..7506ec65 100644 --- a/packages/api/test/static-routing.test.ts +++ b/packages/api/test/static-routing.test.ts @@ -6,7 +6,7 @@ describe("same-origin static ownership", () => { it("serves explicit deep links with an external-bundle policy and revalidated entry HTML", async () => { const fetch = vi.fn(async (request: Request) => new Response(request.method === "HEAD" ? null : "entry", { headers: { "Content-Type": "text/html" } })); const env = { ASSETS: { fetch } } as unknown as Env; - for (const path of ["/", "/jobs", "/jobs/new", "/jobs/id/edit", "/jobs/id/settings", "/job-runs", "/job-runs/id", "/settings/authorized-clients", "/auth/verify?token=one-time", "/authorize?client_id=test", "/device?user_code=ABCD-2345"]) { + for (const path of ["/", "/jobs", "/jobs/new", "/jobs/id/edit", "/jobs/id/settings", "/projects", "/projects/new", "/projects/id", "/job-runs", "/job-runs/id", "/settings/authorized-clients", "/auth/verify?token=one-time", "/authorize?client_id=test", "/device?user_code=ABCD-2345"]) { const response = await staticApp(new Request(`https://app.factorize.sh${path}`), env); expect(response?.status).toBe(200); expect(response?.headers.get("content-security-policy")).toBe(STATIC_CSP); @@ -21,7 +21,7 @@ describe("same-origin static ownership", () => { }); it("never forwards backend namespaces, unknown routes or mutations to static hosting", async () => { const fetch = vi.fn(); const env = { ASSETS: { fetch } } as unknown as Env; - for (const path of ["/api/v1", "/api/v1/unknown", "/api/v1/jobs", "/oauth/token", "/auth/linear", "/auth/github/setup", "/webhooks/github", "/internal/missing", "/mcp", "/healthz", "/.well-known/oauth-authorization-server", "/unknown", "/assets/subdir/file.js", "/index.html", "/jobs/id/edit/extra", "/jobs/id/settings/extra", "/jobs/id/unknown"]) { + for (const path of ["/api/v1", "/api/v1/unknown", "/api/v1/jobs", "/oauth/token", "/auth/linear", "/auth/github/setup", "/webhooks/github", "/internal/missing", "/mcp", "/healthz", "/.well-known/oauth-authorization-server", "/unknown", "/assets/subdir/file.js", "/index.html", "/jobs/id/edit/extra", "/jobs/id/settings/extra", "/jobs/id/unknown", "/projects/id/unknown"]) { expect(await staticApp(new Request(`https://app.factorize.sh${path}`), env)).toBeNull(); } for (const method of ["POST", "PUT", "DELETE", "OPTIONS"]) for (const path of ["/jobs", "/authorize", "/device", "/assets/index-hash.js", "/auth/login"]) expect(await staticApp(new Request(`https://app.factorize.sh${path}`, { method }), env)).toBeNull();