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

588
Vistas
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource (Reason: CORS request did not succeed)

How to set cors in node.js for socket.io v2.2.0?(ngx-socket-io:3.4.0).

Tried to set like following but not able to make connection:

var http = require('http');
var {app,io} = require('../router/nexusservices.router');
var wfwsdk = require('wfw-sdk');
var Service = wfwsdk.getServiceConfigurations('nexusservices');

if (Service) {
 var port = normalizePort(Service.port);
 
  // fix Cross-Origin Request Blocked issue
 app.use(function (req, res, next) {
     res.header("Access-Control-Allow-Origin", "*");
     res.header("Access-Control-Allow-Headers", "*");
     res.header("Access-Control-Allow-Methods", "*");
     if (req.method === "OPTIONS") {
        return res.status(200).end();
     }
     next();
 });

 app.set('port', port);
 /**
 * Create HTTP server.
 */
 var server = http.createServer(app);

 server.listen(port);
 server.on('error', onError);
 server.on('listening', onListening);
  
 io.attach(server);
 io.set('origins', '*:*'); //////// not working
over 4 years ago · Santiago Trujillo
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