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);