我的计划是将令牌发送到服务器。我可以在page.vue
中编写这个脚本(而且它运行得很好(:
mounted() {
this.socket = this.$nuxtSocket({
channel: "/",
auth: {
token: 'abc'
}
})
} // socket.handshake.auth.token = abc
但我需要nuxt.config.js,
上的选项,这是我的尝试:
io: {
sockets: [{
url: 'http://localhost:3000',
auth: {
token: 'abc'
},
}]
}, // socket.handshake.auth.token = undefined
感谢您的帮助!
如果我的问题不清楚,很抱歉,无论如何,我使用内置的RuntimeConfig解决了它,并在page.vue中调用它。我不确定它是否安全,但它可以解决我的问题。