Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

282
Vistas
socket.io origin set but anyways getting errors

i'm making a website for a school project where there is a live updating table with data about how many rounds player have ran. It's almost done, but i'm getting one error, i can't solve:

ccess to XMLHttpRequest at 'https://creeperhd.de:8443/socket.io/?EIO=4&transport=polling&t=O88eQ0_' from origin 'https://creeperhd.de' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I already have this in my server code to prevent this error:

const io = require('socket.io')(http,{cors:{origin:"*"}});

But i anyways get the same error...

Can somebody tell what i can do?

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

You will need to do one of two things to either enable CORS support or bypass CORS restrictions.

Option #1: Change the client-side to skip socket.io http polling by changing the client-side connection code to add an option like this:

const socket = io("https://example.com", {
  transports: ["websocket"] // use webSocket only
});

It is the initial socket.io http polling that trips up on CORs restrictions. If you skip that and go straight to a webSocket connection, then webSocket connections are not limited by CORs so you won't run into CORs access issues.

Option #2: Install the CORS package on your http server and configure it appropriately to enable CORS access for your socket.io endpoint. The CORs page is here. The socket.io doc for enabling CORS access is here.

The cors options shown for socket.io depend upon the CORS package being installed on your web server. So, you have to use both of these together or implement your own custom CORs handling to fully enable CORs access.

about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda