Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/core/dev-server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ class DevServer {
fromNodeMiddleware(
serveStatic(asset.dir, {
dotfiles: "allow",
setHeaders(res, path) {
if (path.endsWith(".gz")) {
res.setHeader("Content-Encoding", "gzip");
}
// Or expand to other encodings if needed
},
})
)
);
Expand Down
Binary file added test/fixture/public/build/test.js.gz
Binary file not shown.
8 changes: 8 additions & 0 deletions test/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,14 @@ export function testNitro(
expect(headers["content-type"]).toBe("text/plain; charset=utf-8");
});

it("serve static asset /build/test.js.gz", async () => {
const { status, headers } = await callHandler({
url: "/build/test.js.gz",
});
expect(status).toBe(200);
expect(headers["content-encoding"]).toBe("gzip");
});

it("stores content-type for prerendered routes", async () => {
const { data, headers } = await callHandler({
url: "/api/param/prerender4",
Expand Down