Getting the request source in a Django request

So, I'm trying to enable resource sharing in the original context in Django, so I can publish it to an external site, and it is easy to do this when I install

response["Access-Control-Allow-Origin"]="*" 

but I want it to check instead whether the source is on the allowed list of sources (essentially to limit it to only allowed specific sites), but I can not find anywhere in the Django request where I can get information about the incident.

I tried using request.META ['HTTP_HOST'] , but that just returns the site you sent the message to. Does anyone know where in the Request object I can get the source of the request?

+4
source share
3 answers

I highly recommend you use django-cors-headers . It allows you to determine CORS_ORIGIN_WHITELISTwhich is a list of allowed sources in a more pythonic way.

+1
source

As for getting url from request(this is what I was looking for), use request.META['HTTP_REFERER']instead.

+4
source

"- , " " ?", request.META ['REMOTE_ADDR'] , ?

0

All Articles