javascript – I want my node.js app to get the headers from the requesting page

 

I have a page that makes GET request to my node.js file. I want to get the headers from that page. Also, its a PHP page so it will change every time. This is the code for my server side app.js file:

const app = require("express")();
const httpServer = require("http").createServer(app);
const io = require("socket.io")(httpServer, {
  path: "/myapp/"
});
var header = req.headers['host'];

io.on('connection', (socket) => {
  let addedUser = false;

  // when the client emits 'add user', this listens and executes
  socket.on('add user', () => {
    
    socket.username = header;

I dont get any errors but I get nothing at all either. Why is that?

Source link