1

I ran a socket.io client code using the liveserver extension on vscode and because i am using the version 2.5.0 i had to make use of socket.io wildcard I then ran the code and got 2 errors in the console..here is the picture from the first error there's apparently a problem with the second line of the code which is var BuiltInEmitter = require('events').EventEmitter

'use strict'
var BuiltInEmitter = require('events').EventEmitter

module.exports = function (CustomEmitter) {
  var Emitter = CustomEmitter || BuiltInEmitter
  var emit = Emitter.prototype.emit

  function onevent (packet) {
    var args = packet.data || []
    if (packet.id != null) {
      args.push(this.ack(packet.id))
    }
    emit.call(this, '*', packet)
    return emit.apply(this, args)
  }

  return function (socket, next) {
    if (socket.onevent !== onevent) {
      socket.onevent = onevent
    }
    return next ? next() : null
  }
}

the other error is from the client code I inputted var patch = require('socketio-wildcard')(io.Manager); patch(socket);.... it doesn't recognise the 'require' ..And as for the other question, the server I'm trying to make this connection to has a set ORIGIN header let's say its https://xterm.com how can I make the ORIGIN header on the client side https://xterm.com instead of http://127.0.0.1:5500 ... thanks

Exboy
  • 79
  • 7
  • Post the error text here as text, not just as image. – deceze Mar 03 '23 at 05:38
  • If you just read it you'd know i did... I made an edit just now – Exboy Mar 03 '23 at 05:39
  • @deceze if you are unclear about anything please ask – Exboy Mar 03 '23 at 05:39
  • The verbatim error message isn’t in your question, but well… Looks like you’re running code that is meant to be run on the backend in node in the browser instead!? – deceze Mar 03 '23 at 06:05
  • I'll use browserify to solve the require problem thanks... do you have an idea of the ORIGIN problem.. thanks in advance @deceze – Exboy Mar 03 '23 at 10:36

1 Answers1

-1

For the wildcard issue, I had to install the library.. and as for the origin issue.. it can't be changed in the browser.. the browser automatically sets it.. if you want to change it you could make use of proxy servers

Exboy
  • 79
  • 7