Refactored the referrer retrieval method for relayed requests