0

I'm building a chat app using socket.io: 2.0.2, nuxt: 2, vue-socket.io: 3.0.10. The app works fine locally, but socket.ui stops responding after uploading to the server. How can this problem be solved?

server:

const io = require('socket.io')(3001, {
  cors: {
    origin: '*'
  }
})

io.on('connection', (socket) => {
 ...code
})

export default function (req, res, next) {
  next()
}

client:

import Vue from 'vue'
import VueSocketIO from 'vue-socket.io'

export default function ({ store }) {
  Vue.use(
    new VueSocketIO({
      debug: false,
      connection: 'http://localhost:3001',
      vuex: {
        store,
        actionPrefix: 'SOCKET_',
        mutationPrefix: 'SOCKET_'
      }
    })
  )
}

i tried to write

connection: 'http://app.com:3001' 

for the client, but it didn't solve the problem

i-akmalov
  • 11
  • 3
  • I'm not an expert in nuxt. But are you sure your port 3001 is accessible? and is it http or https? Anyways, you might want to sub-domain your 3001 web socket to ws.your-domain.com. – Vince Banzon Aug 23 '23 at 11:37

0 Answers0