trquoccuong
trquoccuong

Reputation: 2873

Server Sent Event cant work on production environment

I make a simple server send event with nodejs. It run perfectly on localhost. When I upload it to my VPS. The request to subscribe link is pending. I cant get any message from backend. Same issues on Chrome and Safari, no console error . In Chrome this request like image : enter image description here

Upvotes: 0

Views: 966

Answers (1)

trquoccuong
trquoccuong

Reputation: 2873

I found this problem. It a nginx problems. Add some config to nginx

location / {
  proxy_pass        http://127.0.0.1:3000;
  proxy_buffering off;
  proxy_cache off;
  proxy_redirect    off;
  proxy_set_header Connection '';
  proxy_http_version 1.1;
  chunked_transfer_encoding off;
  proxy_set_header  Host $host;
  proxy_set_header  X-Real-IP  $remote_addr;
}

Upvotes: 2

Related Questions