title: SSE and NodeJS Express
body: <p>Cannot get SSE events to file in browser.</p>
  
  <p>This the server code (express):</p>
  
  <pre><code>app.all('/callme', function(req, res){
      res.writeHead(200, {
        'Connection': 'keep-alive',
        'Content-Type': 'text/event-stream',
        'Cache-Control': 'no-cache'
      });
  
      setInterval(function(){
        console.log('writing');
        res.write((new Date()).toString() + '\n');
      }, 1000);
  })
  </code></pre>
  
  <p>This the client code:</p>
  
  <pre><code>var source = new EventSource('/events');
  source.onmessage = function(e) {
        document.body.innerHTML += e.data + '&lt;br&gt;';
  };
  </code></pre>
  
  <p>I use this same server code using XHR on the client and it works.  The server appears to be sending the data correctly, but not getting fired in the browser..</p>
  
  <p><strong>I've already read <a href="https://stackoverflow.com/questions/12978466/javascript-eventsource-sse-not-firing-in-browser">JavaScript EventSource SSE not firing in browser</a></strong>  Doesn't seem to apply here, as I'm not running anti-virus that would affect it.</p>