Forum Discussion

VikasB's avatar
VikasB
Boss
3 years ago

Get request origin in endpoints

I want to get the request origin in endpoint. For example, I have created a endpoint - 

https://community-stage.khoros.com/eksre65699/plugins/custom/khoros/khoros/grz.users-metrics

Now I want to keep this endpoint open only for specific origin like if request is coming from Khoros website then it should return the result but if request is coming from any other website it should return "Anauthorised Request" as a response. 

1 Reply

  • Hi VikasB 

    Context object http.request.referrer can do the trick for you. Please refer to the documentation for the same here

    It will provide the the absolute URL of the origin and you can always use contains() method to check the index of the string you want to check.

    Let me know if this helps 🙂