fix: add Content-Type header for static files

This commit is contained in:
cany748 2024-03-23 18:23:32 +07:00 committed by Philip H
parent c2829d79e0
commit 8d00c5456a
1 changed files with 6 additions and 0 deletions

View File

@ -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,