E
E
Enfiladed2019-10-09 20:43:56
css
Enfiladed, 2019-10-09 20:43:56

Why is socket.io-client throwing 404?

Hello!
socket.io-client throws an error:

GET http://localhost:3000/socket.io/?EIO=3&transport=polling&t=MsnbnSd 404 (Not Found)

Already corrected 3 errors, I don’t know how.
server(nodejs):
const fs = require("fs")
let app = require("express")();

const http = require("http").createServer(app)
const socket = require("socket.io")(http)

let port = 3000;

app.get("/", function(req, res) {
   res.sendFile(__dirname + "/public/index.html")
})

app.use(function(req, res, next) {
        res.header("Access-Control-Allow-Origin", "http://localhost:8080");
        res.header("Access-Control-Allow-Headers", "X-Requested-With");
        res.header("Access-Control-Allow-Headers", "Content-Type");
        res.header("Access-Control-Allow-Methods", "PUT, GET, POST, DELETE, OPTIONS");
        res.header("Access-Control-Allow-Credentials", "true");
        next();
    });

socket.on('connection', function(socket){
  console.log('a user connected');
});

app.listen(port, function() {
   console.log(`Сервер успешно запущен, порт - ${port}`)
})

and client(vuejs)
mounted: function() {
         let socket = io("localhost:3000", {origins: "domain_1:http://localhost:3000"});
         socket.on('news', function(data) {
            console.log(data)
         })
      }

Has anyone experienced this? Any ideas? Thanks in advance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2018-07-06
@webinar

I would take svg (flexibly, optimally) or as Ankhena already suggested border-image But I still don’t understand border-image, I think I need a female mindset to use border-image. NO OFFENSE. Female == different != bad

M
Michael, 2019-10-09
@Lisey

instead of this

app.listen(port, function() {
  console.log(`Сервер успешно запущен, порт - ${port}`);
});

This
http.listen(port, function() {
  console.log(`Сервер успешно запущен, порт - ${port}`);
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question