I'm using node.js 16 with es6 support enabled and express js,
import express from 'express'
import http from 'http'
const app = express()
app.get('/health', (_req, res, _) => {
console.log('health check')
res.sendStatus(200)
},
const server = http.createServer(app)
server.listen(
8000, '127.0.0.1'
)
here everything works fine, sending get request on localhost:8000/health return 200
But when I attach socket.io to my HTTP server I get the following error
Server returned nothing (no headers, no data)
I added socket.io like so
import { Server } from 'socket.io'
onst io = new Server()
io.attach(server)
Hints everything was working fine with nodejs 14 that's how my package.json lunch scipt look like
"main": "src/index.js",
"type": "module",
"scripts": {
"dev": "nodemon --es-module-specifier-resolution=node src/index.js",
},
I get no error when starting the server
CodePudding user response:
The Issue was with Insomnia , when I tried curl it worked
