|
@@ -1,3 +1,4 @@
|
|
|
+import { Agent } from 'node:http'
|
|
|
import { fileURLToPath, URL } from 'node:url'
|
|
|
import vue from '@vitejs/plugin-vue'
|
|
|
import vueJsx from '@vitejs/plugin-vue-jsx'
|
|
@@ -81,6 +82,22 @@ export default defineConfig(({ mode }) => {
|
|
|
changeOrigin: true,
|
|
|
secure: false,
|
|
|
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()
|
|
|
+ })
|
|
|
+ },
|
|
|
},
|
|
|
},
|
|
|
},
|