Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

how to use socket io with express in the same time

import express from 'express'
import http from 'http'
import { Server } from 'socket.io'

const expressApp = express()
const server = http.createServer(expressApp)

const io = new Server(server, {
  cors: {
    origin: allowedOrigins, // string[]
    methods: ['GET', 'POST'],
    allowedHeaders: [],
    credentials: true
  }
})

expressApp.get('/test', (req, res, next) => {
	res.sendStatus(200)
})

server.listen(80)

io.on('connection', () => {})
 
PREVIOUS NEXT
Tagged: #socket #io #express #time
ADD COMMENT
Topic
Name
3+8 =