mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-18 14:41:25 +00:00
examples(with-sockets): fix cannot read property 'app' of undefined on nuxt build (#6586)
This commit is contained in:
parent
b031fac121
commit
b8e1a7170d
@ -2,6 +2,7 @@ import http from 'http'
|
|||||||
import socketIO from 'socket.io'
|
import socketIO from 'socket.io'
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
|
this.nuxt.hook('render:before', (renderer) => {
|
||||||
const server = http.createServer(this.nuxt.renderer.app)
|
const server = http.createServer(this.nuxt.renderer.app)
|
||||||
const io = socketIO(server)
|
const io = socketIO(server)
|
||||||
|
|
||||||
@ -21,4 +22,5 @@ export default function () {
|
|||||||
socket.broadcast.emit('new-message', message)
|
socket.broadcast.emit('new-message', message)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user