GET http://localhost:8080/socket.io/?EIO=4&transport=polling&t=Oe3Y5xL 404 (Not Found) [closed]

I am facing this issue:

GET http://localhost:8080/socket.io/?EIO=4&transport=polling&t=Oe3Y5xL 404 (Not Found)

What to do to solve this issue? I am stuck at this problem.

backend code at server.js 
const express = require('express');
const app = express();
app.use(express.json());
require('dotenv').config();
const cors = require('cors');
app.use(cors());

const http = require('http');
const server = http.createServer(app);
const io = require('socket.io')(server);

const dbConfig = require('./config/dbConfig');


io.on('connection', (socket) => {
   console.log('user connected successfully');
   socket.on('disconnect', () => {
      console.log('user dis connected disconnected');
   })
})

const port = process.env.PORT || 8080;
app.listen(port, () => console.log(`server has been started on ${port}`));

This is the frontend code for calling the backend socket

import io from 'socket.io-client';

const socket = io.connect('http://localhost:8080');


socket.on('connect', () => {
     console.log('user connected ');
})
socket.on('disconnect', () => {
     console.log('user disconnected');
 })

export default socket;



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation