fix: set default charset for Astro pages in dev

This commit is contained in:
bholmesdev 2022-07-11 15:16:33 -04:00
parent bf5d1cc1e7
commit f4e96129ee
2 changed files with 9 additions and 0 deletions

View file

@ -326,6 +326,9 @@ async function handleRequest(
}
} else {
const result = await ssr(preloadedComponent, options);
if (!result.headers.has('Content-Type')) {
result.headers.set('Content-Type', 'text/html;charset=utf-8');
}
return await writeSSRResult(result, res);
}
} catch (_err) {

View file

@ -42,5 +42,11 @@ describe('Pages', () => {
expect($('#testing').length).to.be.greaterThan(0);
});
it('Has default Content-Type with charset=utf-8', async () => {
const html = await fixture.fetch('/');
expect(html.headers.get('Content-Type')).to.equal('text/html;charset=utf-8');
});
});
});