From 8d00c5456a9e9f8ed697c1441e6e24dbdd13094b Mon Sep 17 00:00:00 2001 From: cany748 Date: Sat, 23 Mar 2024 18:23:32 +0700 Subject: [PATCH] fix: add Content-Type header for static files --- src/lib/Server.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/Server.js b/src/lib/Server.js index b6b2f5f4..18e015cb 100644 --- a/src/lib/Server.js +++ b/src/lib/Server.js @@ -225,6 +225,12 @@ module.exports = class Server { return; } + if (id.endsWith('.html')) setHeader(event, 'Content-Type', 'text/html'); + if (id.endsWith('.js')) setHeader(event, 'Content-Type', 'application/javascript'); + if (id.endsWith('.json')) setHeader(event, 'Content-Type', 'application/json'); + if (id.endsWith('.css')) setHeader(event, 'Content-Type', 'text/css'); + if (id.endsWith('.png')) setHeader(event, 'Content-Type', 'image/png'); + return { size: stats.size, mtime: stats.mtimeMs,