I have a problem: I am developing an API view in django that must respond to remote requests.
Is there a way to know what is the url from which the API call starts?
Thank you
I have a problem: I am developing an API view in django that must respond to remote requests.
Is there a way to know what is the url from which the API call starts?
Thank you
Yes, in the HTTP headers, there will be a Referer line, which is the URI from which the client came, if they choose to send it. Some people choose to do things so it isn't sent, and in that case, there isn't much you can do about it.
There are several posts about parsing HTTP headers floating around, you can just use one of those and borrow their methods.
This is one of the posts that has several good examples in it: Parse raw HTTP Headers
You just need to make Django snag the headers so you can parse them, which isn't difficult to do, I believe there are functions in the standard library for getting headers in web apps.