Answer the question
In order to leave comments, you need to log in
How to connect socket.io to express when deploying to ZEIT?
Hello everyone, the question is, how to connect socket.io to express when building and deploying to ZEIT through now? On local in development mode, everything works.
I use Next.js + Express and upload it all to ZEIT.
now.js
"builds": [
{ "src": "server/**/*.js", "use": "@now/node" },
{ "src": "package.json", "use": "@now/next" }
],
"routes": [
{ "src": "/api/(.*)", "dest": "/server/src/server.js" },
{ "src": "/socket.io/(.*)", "dest": "/server/src/server.js" },
{ "src": "/(.*)", "dest": "/$1" }
]
const _server = server.listen(8080, (err) => {
if (err) throw err
console.log('Server is started :)')
})
const io = socketIO(_server, { serveClient: false });
import io from 'socket.io-client';
const socket = io('https://url....', { secure: true });
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question