diff --git a/.changeset/thick-lines-follow.md b/.changeset/thick-lines-follow.md new file mode 100644 index 00000000000..20a42bcbca2 --- /dev/null +++ b/.changeset/thick-lines-follow.md @@ -0,0 +1,5 @@ +--- +'@tanstack/start-plugin-core': minor +--- + +fix streaming in vite preview diff --git a/packages/start-plugin-core/src/preview-server-plugin/plugin.ts b/packages/start-plugin-core/src/preview-server-plugin/plugin.ts index 3257a8323b7..3d2d8a05bf6 100644 --- a/packages/start-plugin-core/src/preview-server-plugin/plugin.ts +++ b/packages/start-plugin-core/src/preview-server-plugin/plugin.ts @@ -50,6 +50,10 @@ export function previewServerPlugin(): Plugin { const webReq = new NodeRequest({ req, res }) const webRes: Response = await serverBuild.fetch(webReq) + if (webRes.headers.get('content-type')?.startsWith('text/html')) { + res.setHeader('content-encoding', 'identity') + } + // Temporary workaround // Vite preview's compression middleware doesn't support flattened array headers that srvx sets // Call writeHead() before srvx to avoid corruption