mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
fix(vite): [dev proxy] sse not close
This commit is contained in:
parent
ca5462c11d
commit
f7e3c528c9
1 changed files with 17 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import { Agent } from 'node:http'
|
||||||
import { fileURLToPath, URL } from 'node:url'
|
import { fileURLToPath, URL } from 'node:url'
|
||||||
import vue from '@vitejs/plugin-vue'
|
import vue from '@vitejs/plugin-vue'
|
||||||
import vueJsx from '@vitejs/plugin-vue-jsx'
|
import vueJsx from '@vitejs/plugin-vue-jsx'
|
||||||
|
@ -81,6 +82,22 @@ export default defineConfig(({ mode }) => {
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
secure: false,
|
secure: false,
|
||||||
ws: true,
|
ws: true,
|
||||||
|
timeout: 5000,
|
||||||
|
agent: new Agent({
|
||||||
|
keepAlive: false,
|
||||||
|
}),
|
||||||
|
onProxyReq(proxyReq, req) {
|
||||||
|
proxyReq.setHeader('Connection', 'keep-alive')
|
||||||
|
if (req.headers.accept === 'text/event-stream') {
|
||||||
|
proxyReq.setHeader('Cache-Control', 'no-cache')
|
||||||
|
proxyReq.setHeader('Content-Type', 'text/event-stream')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onProxyReqWs(proxyReq, req, socket) {
|
||||||
|
socket.on('close', () => {
|
||||||
|
proxyReq.destroy()
|
||||||
|
})
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue