Closed atinux closed 3 years ago
Woah, it looks awesome! But one thing should be kept in mind: SSE is kind of abandoned technology: https://github.com/whatwg/html/issues/2177#issuecomment-332071504
Maybe someday it will need to be rewritten to Fetch API implementation (according to the link). For example to enable auth-headers support.
That's pretty sad, I see really nice progress with SSE and great advantages VS sockets.
There is also a promising project: https://github.com/dunglas/mercure
So, no nuxt/sse ? :) I got a :
EventSource's response has a MIME type ("application/json") that is not "text/event-stream". Aborting the connection.
because of the webpack HMR I guess. Any update on this ? :)
I think this may not be added because of serverless support.
Hello @Atinux
any doc anywhere about sse?
This is tricky since it depends of a Node.js server, take a look at tutorials for node such as https://www.digitalocean.com/community/tutorials/nodejs-server-sent-events-build-realtime-app
Just wanted to link this issue with my current progress at using SSE in Nuxt3. Basically I'm stuck because unjs/h3 seems to close the connection no matter what I do.
See this issue and reproduction repository for details.
Introduction
Introducing a Server-sent events module for Nuxt to let serverMiddleware and functions to send events to the Nuxt app.
An instance will be available with
nuxt.$sse
to send events.nuxt.config.js
:On the app side, it will expose a
$sse
instance with.on('eventName', fn)
.pages/tweets.vue
:How does it work?
@nuxt/sse
will:/_nuxt/sse
(see more here)nuxt.$sse
$sse
in the Nuxt app on client-side withthis.addPlugin
+ auto connect + customisable with a custom endpointWith this system, modules author could inject this module to add some realtime data to the Nuxt app easily š
PS: 0 breaking change š