From 9e7c43edd048e097e57838f6ae9462e09bae4427 Mon Sep 17 00:00:00 2001 From: lsy Date: Mon, 16 Feb 2026 13:37:59 +0800 Subject: [PATCH] =?UTF-8?q?~=E4=BC=98=E5=8C=96arangler=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/worker/src/index.ts | 15 +++++++++++++++ apps/worker/wrangler.toml | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/apps/worker/src/index.ts b/apps/worker/src/index.ts index 9440f78..247af87 100644 --- a/apps/worker/src/index.ts +++ b/apps/worker/src/index.ts @@ -111,4 +111,19 @@ app.route("/api/group", newapiGroupRoutes); app.route("/v1", proxyRoutes); +app.notFound((c) => { + const path = c.req.path; + if ( + path === "/api" || + path.startsWith("/api/") || + path === "/v1" || + path.startsWith("/v1/") + ) { + return c.json({ error: "Not Found" }, 404); + } + const assets = (c.env as { ASSETS?: { fetch: (input: Request) => Promise } }) + .ASSETS; + return assets ? assets.fetch(c.req.raw) : c.text("Not Found", 404); +}); + export default app; diff --git a/apps/worker/wrangler.toml b/apps/worker/wrangler.toml index 0e36c6b..de16418 100644 --- a/apps/worker/wrangler.toml +++ b/apps/worker/wrangler.toml @@ -14,5 +14,6 @@ database_id = "00000000-0000-0000-0000-000000000000" [assets] directory = "../admin/dist" +binding = "ASSETS" not_found_handling = "single-page-application" -run_worker_first = ["/api/*", "/v1/*"] +run_worker_first = true