vite-ssr
vite-ssr copied to clipboard
`handleSsrRequest` should set status code or it will return 404 when using Koa
When using Koa as server in development, SSR requests will return 404.
Because of Koa will set status code to 404 by default, and handleSsrRequest()
doesn't set status code, so finally it will response status code 404 not 200.
Example:
const Koa = require('koa');
const c2k = require('koa-connect');
const { createSsrServer } = require('vite-ssr/dev');
const app = new Koa();
async function bootstrap() {
const viteServer = await createSsrServer({
server: { middlewareMode: 'ssr' },
});
app.use(c2k(viteServer.middlewares));
app.listen(3000);
}
bootstrap();
