[Fixed] Expressjs cant get origin or referer


Is it possible to find out where are users coming from when the click a link which points to my site?

Lets assume I own http://example.com and a link (http://example.com/foobar) is placed on http://example.net/path/to/subsite. .net is not my site

Now, when a visitor comes from example.net by clicking the link. Am I able to get the origin somehow?

I run an webserver using express js and I dont know what am I doing wrong here.

const express = require('express')
const router = express.Router()
router.use(function (req, res, next) {
  const origin = req.get('origin')
  const host = req.get('host')
  // Nothing here tells me the origin.
  console.log(origin, host, req.headers)


This will give you the URL which is calling your Express.JS API


Leave a Reply

(*) Required, Your email will not be published