Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
formatting, spelling, use example domain, code format example URL
Source Link

I'm using express.js and iI need to know the domain which is originating the call. This is the simple code

app.get(
    '/verify_license_key.json',
    function( req, res ) {
        // do something

How do iI get the domain from the req or the res object? I mean iI need to know if the apiAPI was called by somesite.comsomesite.example or someothersite.comsomeothersite.example. I tried doing a console.dir of both req and res but iI got no idea from there, also read the documentation but it gave me no help.

I'm using express.js and i need to know the domain which is originating the call. This is the simple code

app.get(
    '/verify_license_key.json',
    function( req, res ) {
        // do something

How do i get the domain from the req or the res object? I mean i need to know if the api was called by somesite.com or someothersite.com. I tried doing a console.dir of both req and res but i got no idea from there, also read the documentation but it gave me no help.

I'm using express.js and I need to know the domain which is originating the call. This is the simple code

app.get(
    '/verify_license_key.json',
    function( req, res ) {
        // do something

How do I get the domain from the req or the res object? I mean I need to know if the API was called by somesite.example or someothersite.example. I tried doing a console.dir of both req and res but I got no idea from there, also read the documentation but it gave me no help.

Source Link
Nicola Peluchetti
  • 77k
  • 32
  • 150
  • 197

How do I get the domain originating the request in express.js?

I'm using express.js and i need to know the domain which is originating the call. This is the simple code

app.get(
    '/verify_license_key.json',
    function( req, res ) {
        // do something

How do i get the domain from the req or the res object? I mean i need to know if the api was called by somesite.com or someothersite.com. I tried doing a console.dir of both req and res but i got no idea from there, also read the documentation but it gave me no help.