Jacek
Jacek
NNuxt
Created by Ilya Belov on 10/28/2024 in #❓・help
How to build an SPA + Nitro for server with Nuxt
Preset value is actually node_server (not node-server) and you don't need to put it in the config as it is the default. Build the project into a Docker container or configure your hosting to run server/index.mjs and you should be good to go. Also consider alternative runtimes - Bun if you want to handle more users or Deno for built-in security.
4 replies
NNuxt
Created by Imran on 10/14/2024 in #❓・help
Nuxt dev server from code server
It might be the same. Have you tried suggestion from #16377 yet?
20 replies
NNuxt
Created by Imran on 10/14/2024 in #❓・help
Nuxt dev server from code server
Apologies, I through the error is related to your own use of WebSockets. In case of HMR.. it should be there already. Maybe devServer » https could help force Vite to realize it is loaded with with TLS and switch to wss://.
20 replies
NNuxt
Created by Imran on 10/14/2024 in #❓・help
Nuxt dev server from code server
Examples showing WS usage usually include protocol adjustment
const isSecure = location.protocol === "https:";
const url = (isSecure ? "wss://" : "ws://") + location.host + "/_ws";
const isSecure = location.protocol === "https:";
const url = (isSecure ? "wss://" : "ws://") + location.host + "/_ws";
let me know if it helps 🙂
20 replies
NNuxt
Created by Quei on 10/14/2024 in #❓・help
Reusable websocket component
Because you won't open ws connection straight to client browser - he does not have any URL to point to.
49 replies
NNuxt
Created by Quei on 10/14/2024 in #❓・help
Reusable websocket component
Is the browser involved in it? or is it service-to-service?
49 replies
NNuxt
Created by Quei on 10/14/2024 in #❓・help
Reusable websocket component
Oh.. I may have misunderstood the whole idea. You want to send from client to backend, not the other way around.
49 replies
NNuxt
Created by Quei on 10/14/2024 in #❓・help
Reusable websocket component
If I read it correctly... anytime you open a new connection you close previous one. So you actually support single user for the whole backend instance. Is it meant to run on edge and spin up worker for every user?
49 replies
NNuxt
Created by Quei on 10/14/2024 in #❓・help
Reusable websocket component
It refers to nuxtServerInit from Nuxt 2. Regardless, if you decide to use some "magic" global, beware it won't scale. You can only broadcast to people connected to specific backend instance.
49 replies
NNuxt
Created by Quei on 10/14/2024 in #❓・help
Reusable websocket component
If I read the page correctly, socket lives on the client, so emit just sends message from the browser to the server. I am curious if you can figure out how to utilize it on the backend.
49 replies
NNuxt
Created by Quei on 10/14/2024 in #❓・help
Reusable websocket component
If you can use it to replace unstorage from the last demo on Stackblitz, I would gladly fork it for later 😉
49 replies
NNuxt
Created by Quei on 10/14/2024 in #❓・help
Reusable websocket component
If you think socket.io has dedicated methods that would make your source code more clearly state the intent (readable, maintainable), then I see no reason to seek other solutions 🙂
49 replies
NNuxt
Created by Quei on 10/14/2024 in #❓・help
Reusable websocket component
The only problem is that it is not a solution that clearly speaks "I am dedicated for chat app".
49 replies
NNuxt
Created by Quei on 10/14/2024 in #❓・help
Reusable websocket component
So you said you worry about .clear() before .set(). I wouldn't. It means you use storage as signal bus. It does not matter if it contains an item or not.
49 replies
NNuxt
Created by Quei on 10/14/2024 in #❓・help
Reusable websocket component
Dude.. don't listen to mr-generate-random-plausible-answer-from-noise. Use it for generating tests or something, but don't ask it for tech-related stuff, because it will spit lies from training data and you will never know how much truth is there until you dig the topic yourself.
49 replies
NNuxt
Created by Quei on 10/14/2024 in #❓・help
Reusable websocket component
The 2nd Deno link used SSE.
49 replies
NNuxt
Created by Quei on 10/14/2024 in #❓・help
Reusable websocket component
On the other hand socket.io is an estabilished library and should be a good fit for most cases. Hopefully it won't be a large overhead on top of Nitro.
49 replies
NNuxt
Created by Quei on 10/14/2024 in #❓・help
Reusable websocket component
IMO, frontend should remain dumb and avoid having any logic to "handle" broadcast messages.
49 replies
NNuxt
Created by Quei on 10/14/2024 in #❓・help
Reusable websocket component
What's ugly about it? in-memory KV acts like a queue, you can clear it anytime (even right before when you set the value). The system is then decoupled and queue technology can be swapped (from in-memory to something cloud-based). You can wrap set/watch/clear methods with a custom service API. The only alternative would be to share/leak peer instance on open so some service could call .publish(...) anytime it thinks appropriate, while in real-world scenario you'd end up with an array of peers for all open connections and utilizing .send(...) instead to avoid broadcasting to all chat rooms. Ofc built-in solution would be preferrable, however it is always a trade - flexibility vs convenience 😉
49 replies
NNuxt
Created by Quei on 10/14/2024 in #❓・help
Reusable websocket component
I was trying to outline this in pseudo-code above (mq.subscribe(...)) See this demo based on in-memory KV as queue.
49 replies