Skip to content

Server Sent Events are not working in a nodejs/express app #3765

@thunder7553

Description

@thunder7553

With Caddy 2.2.0, the responses from the server are only sent unbuffered when the content type is text/event-stream. NodeJS express sends out a Content Type of text/event-stream; charset=utf-8.

I am not so deep in the specs to know if caddy or express is at fault. I would expect caddy to gracefully accept any arguments to the content-type: text/event-stream.

Workaround 1

It is possible to get it working with express (by not using express, but the underlaying nodejs function calls directly).

    res.writeHead(200, {
      'Content-Type': 'text/event-stream',
      'Cache-Control': 'no-cache',
      'X-Accel-Buffering': 'no',
      'Transfer-Encoding': 'chunked',
    });

Workaraound 2

Setting flush_interval to -1 in the Caddyfile works as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐞Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions