Unverified Commit dabb4d87 authored by yqwoe's avatar yqwoe Committed by GitHub

[Fix][Web] Fix web SSE problem (#2191)

* feat: use-service hooks * feat: SSE express代理 * Update MonitorController.java --------- Co-authored-by: 's avatarzhu-mingye <934230207@qq.com>
parent a08b334d
......@@ -34,7 +34,6 @@ import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -66,7 +65,6 @@ public class MonitorController {
}
@GetMapping(value = "/getLastUpdateData", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
@CrossOrigin("*")
@PublicInterface
@ApiOperation("Get Last Update Data")
public SseEmitter getLastUpdateData(Long lastTime) {
......
......@@ -36,9 +36,19 @@ export default {
// target: 'https://preview.pro.ant.design',
// 配置了这个可以从 http 代理到 https
// 依赖 origin 的功能可能需要这个,比如 cookie
secure: false,
changeOrigin: true,
logLevel: 'debug',
pathRewrite: { '^': '' },
}
onProxyRes: (proxyRes, req, res) => {
res.header({
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache, no-transform',
Connection: 'keep-alive',
'X-Accel-Buffering': 'noe',
});
},
},
},
/**
......
......@@ -87,12 +87,7 @@ export async function removeData(url: string, params: [any]) {
});
}
export function getSseData(url: string) {
const {REACT_APP_ENV = 'dev'} = process.env;
// @ts-ignore
const address = proxy[REACT_APP_ENV]["/api/"].target || ""
return new EventSource(address + url);
return new EventSource(url);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment