Skip to content

Commit

Permalink
fix: add Content-Type header for static files
Browse files Browse the repository at this point in the history
  • Loading branch information
cany748 authored and pheiduck committed Mar 23, 2024
1 parent c2829d7 commit 8d00c54
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 8d00c54

Please sign in to comment.