K
K
kAIST2020-05-20 10:33:21
Django
kAIST, 2020-05-20 10:33:21

How to overcome "Referer checking failed" in Django 3?

I implement an API on the site, which is accessed by one of the services. But it doesn't send a referer. The site is on https, and django 3 introduced referer checking on requests. csrf_exempt doesn't help.

class SomeView(APIView):
    permission_classes = (AllowAny,)
    def post(self,request):
        pass

How it is possible to bypass this business?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew, 2020-05-20
@deepblack

CSRF_TRUSTED_ORIGINS

# settings.py
CSRF_TRUSTED_ORIGINS = ['api.yoursite.ru']

And a full error traceback would not hurt.

A
alternativshik, 2020-05-20
@alternativshik

Which side of csrf_exempt to the referrer?
Can you provide the exact and complete text of the error?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question