Serving Nuxt with an Express server
I want to serve Nuxt inside an Express server. Is this possible?
The reason I want to do this is because I have a function that handles incoming websocket requests and deals with them accordingly
Currently using express alongside a node:http server
10 Replies
why not use websockets in nuxt + nitro directly?
https://www.youtube.com/watch?v=OfY7JcrqkPg
Alexander Lichter
YouTube
Integrating WebSockets in Nuxt and Nitro
π Nitro 2.9 was released just before Vue.js Amsterdam and brings new features such as a database layer, a task API and also WebSocket support! But how can we integrate it in a Nuxt application? This video will teach you π
Key points:
π How to set up WebSockets in Nitro and in Nuxt
π‘ Working from scratch to a functional application
β οΈ Hints to m...
Does it function the same way as node:http's upgrade listener?
Nope, not exactly.
Shown in the code/video
Got it. Is there a way to achieve my previous request? Serving Nuxt through Express?
You probably can but I never did π
You can serve express through nuxt though if that helps π
Could elaborate on that? Im basically looking for a way to serve an express app through nitro/nuxt, but can't really find any informations
build your app as usual, then register the handler either in a catchall route (e.g.
/api/[...].ts
) or register it as handler via https://nuxt.com/docs/api/nuxt-config#serverhandlersI'd love to hear why it has to be an express app though and nitro "isn't enough" π
Thanks for the respone! I'll checkt that out π
Well, unfortunately PayloadCMS is built using express.js, im still kind of trying to wrap my head around if it's possible to let a nuxt app and payload run on the same port, though the more i think about it, the more i feel like its quite a lot work π
might work as described above π€ ^
ahh, I see