diff --git a/server.mjs b/server.mjs index 47355e0..3c702c1 100644 --- a/server.mjs +++ b/server.mjs @@ -32,6 +32,19 @@ app.use(compression({ }, })); +// MIME type map for explicit Content-Type headers +const mimeTypes = { + '.css': 'text/css', + '.js': 'application/javascript', + '.mjs': 'application/javascript', + '.json': 'application/json', + '.svg': 'image/svg+xml', + '.png': 'image/png', + '.jpg': 'image/jpeg', + '.webp': 'image/webp', + '.woff2': 'font/woff2', +}; + // Serve static assets with long-term caching // Hashed assets (_assets/) get 1-year immutable cache // Non-hashed assets get 1-hour cache with revalidation @@ -39,6 +52,12 @@ app.use('/_assets', express.static(join(__dirname, 'dist', 'client', '_assets'), maxAge: '1y', immutable: true, etag: false, + setHeaders: (res, filePath) => { + const ext = filePath.slice(filePath.lastIndexOf('.')).toLowerCase(); + if (mimeTypes[ext]) { + res.setHeader('Content-Type', mimeTypes[ext]); + } + }, })); app.use(express.static(join(__dirname, 'dist', 'client'), { diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index 7d63826..f7bb671 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -64,7 +64,7 @@ const shareDescription = encodeURIComponent(post.data.description); />
-
+
@@ -132,7 +132,7 @@ const shareDescription = encodeURIComponent(post.data.description);
-
+ {post.data.heroImage && (