summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/spicy-tomatoes-act.md5
-rw-r--r--examples/ssr/server/server.mjs3
-rw-r--r--packages/astro/src/vite-plugin-astro-server/index.ts5
3 files changed, 9 insertions, 4 deletions
diff --git a/.changeset/spicy-tomatoes-act.md b/.changeset/spicy-tomatoes-act.md
new file mode 100644
index 000000000..f4af5e96c
--- /dev/null
+++ b/.changeset/spicy-tomatoes-act.md
@@ -0,0 +1,5 @@
+---
+"astro": patch
+---
+
+Fix an issue where utf8 encoding was skipped in the dev server.
diff --git a/examples/ssr/server/server.mjs b/examples/ssr/server/server.mjs
index bc495f5c6..b08bed209 100644
--- a/examples/ssr/server/server.mjs
+++ b/examples/ssr/server/server.mjs
@@ -18,7 +18,8 @@ async function handle(req, res) {
const html = await app.render(req, route);
res.writeHead(200, {
- 'Content-Type': 'text/html',
+ 'Content-Type': 'text/html; charset=utf-8',
+ 'Content-Length': Buffer.byteLength(html, 'utf-8'),
});
res.end(html);
} else if (/^\/api\//.test(req.url)) {
diff --git a/packages/astro/src/vite-plugin-astro-server/index.ts b/packages/astro/src/vite-plugin-astro-server/index.ts
index 929040679..2b510cee7 100644
--- a/packages/astro/src/vite-plugin-astro-server/index.ts
+++ b/packages/astro/src/vite-plugin-astro-server/index.ts
@@ -3,7 +3,6 @@ import type http from 'http';
import type { AstroConfig, ManifestData, RouteData } from '../@types/astro';
import { info, LogOptions } from '../core/logger.js';
import { createRouteManifest, matchRoute } from '../core/routing/index.js';
-import mime from 'mime';
import stripAnsi from 'strip-ansi';
import { createSafeError } from '../core/util.js';
import { ssr } from '../core/render/dev/index.js';
@@ -30,8 +29,8 @@ function removeViteHttpMiddleware(server: vite.Connect.Server) {
function writeHtmlResponse(res: http.ServerResponse, statusCode: number, html: string) {
res.writeHead(statusCode, {
- 'Content-Type': mime.getType('.html') as string,
- 'Content-Length': Buffer.byteLength(html, 'utf8'),
+ 'Content-Type': 'text/html; charset=utf-8',
+ 'Content-Length': Buffer.byteLength(html, 'utf-8'),
});
res.write(html);
res.end();