From 525c0f6a34c3dc1365b7cee1d493a500ca22f899 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 10 Feb 2026 01:01:23 +0000 Subject: [PATCH] Return 404 for missing static assets with extensions Co-authored-by: Theo Browne --- apps/t3/src/cli.test.ts | 10 ++++++++++ apps/t3/src/cli.ts | 3 +++ 2 files changed, 13 insertions(+) diff --git a/apps/t3/src/cli.test.ts b/apps/t3/src/cli.test.ts index 1662825f6d..8d172fddf5 100644 --- a/apps/t3/src/cli.test.ts +++ b/apps/t3/src/cli.test.ts @@ -449,6 +449,16 @@ describe("resolveStaticAssetReadTarget", () => { }); }); + it("returns not_found for missing asset files with extensions", () => { + const tempDir = mkdtempSync(path.join(os.tmpdir(), "t3-static-missing-asset-")); + writeFileSync(path.join(tempDir, "index.html"), "ok", "utf8"); + + const result = resolveStaticAssetReadTarget("/assets/missing.js", tempDir); + expect(result).toEqual({ + kind: "not_found", + }); + }); + it("rejects symlinked files that escape the dist directory", () => { const tempDir = mkdtempSync(path.join(os.tmpdir(), "t3-static-symlink-")); writeFileSync(path.join(tempDir, "index.html"), "ok", "utf8"); diff --git a/apps/t3/src/cli.ts b/apps/t3/src/cli.ts index 3311d33141..260c9f5f93 100644 --- a/apps/t3/src/cli.ts +++ b/apps/t3/src/cli.ts @@ -505,6 +505,9 @@ export function resolveStaticAssetReadTarget( if (requestedFile.kind === "file") { return requestedFile; } + if (path.extname(requestedPath.filePath).length > 0) { + return { kind: "not_found" }; + } const indexPath = path.join(normalizedDistRoot, "index.html"); const indexFile = resolveSafeFilePathInDist(indexPath, realDistRoot);