You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
require('dotenv').config();constexpress=require('express');constserver=express();consthttp=require('http').createServer(server);constcors=require('cors');constio=require('socket.io')(http,{cors: {origin: "localhost:8080",methods: ["GET","POST"]}});consthistory=require('connect-history-api-fallback');constserveStatic=require('serve-static');constmongoose=require('mongoose');mongoose.connect(process.env.DATABASE_URL,{useNewUrlParser: true});constdb=mongoose.connection;db.on('error',(error)=>console.log(error));db.once('open',()=>console.log('Connected to Database!'))server.use(express.json());server.use(cors());server.use(history());io.on('connection',(socket)=>{console.log("a user connected");})constrouter=require('./pollPage');server.use('/pollPage',router);server.use(serveStatic('../dist'))server.listen(process.env.PORT||3000,()=>console.log("server started!"))
What am I doing wrong and how do I fix this? I'm using Express ^3.1.1 both on server and client
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm having trouble connecting to my socket io server. When I followed the troubleshooting documentation it gives me an error:
here is my server code:
What am I doing wrong and how do I fix this? I'm using Express ^3.1.1 both on server and client
Beta Was this translation helpful? Give feedback.
All reactions