Find domain originating the request in fastify server

Viewed 30

In express we can access it like

var origin = req.get('origin');

How do we achieve the same in fastify server?

What have I tried so far: I know that fastify allows us to access request.id. But I am looking to find the domain. I have also tried reading the hostname parameter, but it is the hostname of the server(www.local-demo.com:8080).

How do find the domain originating the request.

1 Answers

Reading the express documentation, req.get('origin') reads the HTTP origin header.

So, to do the same with Fastify you need to write:

const httpHeader = request.headers.origin

As reminder: all the HTTP Headers are lower case

Related