I have a google cloud API function that is built on Node.js. I want to find the source of API request. I mean request header referer. I have tried using req.get('referer') but that was returning null. Can I access this information in any other way? Please help
            Asked
            
        
        
            Active
            
        
            Viewed 356 times
        
    0
            
            
        - 
                    It is not unexpected for the referrer to sometimes be null (or always, in the case of all requests coming in from a client that doesn't send one) – Kevin B Jul 14 '22 at 18:04
- 
                    Hi @Meera, was my answer helpful ? – Jose German Perez Sanchez Jul 19 '22 at 15:53
1 Answers
1
            
            
        Doing a quick test for the same situation you're handling, it works without any issue.
It was tested with: curl “<FUNCTION_ URL>” --referer "https://google.com"
And to get the request header, I used: req.get(‘Referrer’)
Have in mind that if the URL is not valid, the result would be undefined, as follows:
If the solution provided still does not work, it might be an issue with your request to Cloud Functions.
 
    
    
        Jose German Perez Sanchez
        
- 1,103
- 4
- 16
 
    