vite-plugin-virtual-html icon indicating copy to clipboard operation
vite-plugin-virtual-html copied to clipboard

[vite] Internal server error: Cannot set headers after they are sent to the client

Open catouse opened this issue 1 year ago • 1 comments

[vite] Internal server error: Cannot set headers after they are sent to the client
      at new NodeError (node:internal/errors:372:5)
      at ServerResponse.setHeader (node:_http_outgoing:576:11)
      at send (/home/user/projects/my_project/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-80fe9c6b.js:57369:9)
      at viteIndexHtmlMiddleware (/home/user/projects/my_project/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-80fe9c6b.js:57779:28)

The options of virtualHtml is:

{
  pages: { index: '/index.html', button: '/lib/button/index.html' },
  indexPage: 'button'
}

catouse avatar Jun 29 '22 07:06 catouse

Looks like it caused by this:

https://github.com/windsonR/vite-plugin-virtual-html/blob/7fe8d8100d1863ce176b96ae1b93f6ba6b88ec6e/src/plugin.ts#L51

maybe you can test this. use res.end to replace res.write in src/plugin.js.

windsonR avatar Jun 29 '22 08:06 windsonR

long time no response, so close this issue.

windsonR avatar Sep 12 '22 02:09 windsonR