Yes.
Yes.
node -v: v8.8.1npm -v: 5.5.1npm ls react-scripts (if you haven鈥檛 ejected): [email protected]Then, specify:
I've got an existing app that I'd like to rewrite using React. The app has a Go backend that provides an EventSource endpoint. I attempted to use the proxy functionality of the development server to route requests for the endpoint to the Go backend.
Example Backend:
func handleEvents(rw http.ResponseWriter, req *http.Request) {
rw.Header().Set("Content-Type", "text/event-stream")
for i := 0; true; i++ {
_, err := fmt.Fprintf(rw, "data: %v\n\n")
if err != nil {
break
}
rw.(http.Flusher).Flush()
}
}
Example Frontend:
let es = new EventSource('/events');
es.onmessage = (msg) => {
console.log(msg);
};
It should print a list of numbers in the browser console.
Nothing happens at all until I kill the Go backend process, at which point all of the events that the backend had sent arrive suddenly all at once. The EventSource also occasionally calls its onerror callback and then disconnects suddenly for no apparent reason.
Note also that the code works completely fine if I serve the files produced by npm run build directly from the Go backend.
Have you come up with any workarounds in the meantime? Having the same issue...
We're happy to take fixes for this if you have suggestions.
After lurking around the internet having the same problem, I think this is related to #966. I think an ok fix would be to toggle webpack dev server's compression via an ENV variable of some kind.
A workaround might be to enable CORS on the SSE server and connect to it directly
I think the fix recommended was to set Cache-Control in the SSE headers.
https://github.com/facebook/create-react-app/issues/1633
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 7 days if no further activity occurs.
Most helpful comment
After lurking around the internet having the same problem, I think this is related to #966. I think an ok fix would be to toggle webpack dev server's compression via an ENV variable of some kind.
A workaround might be to enable CORS on the SSE server and connect to it directly