How to fix django cors issue

create a file middleware.py and type

class CORSMiddleware:

    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request):
        response = self.get_response(request)
        response['Access-Control-Allow-Origin'] = "*"
        return response

In settings.py

add

MIDDLEWARE = [
    ...
    'product.middleware.CORSMiddleware',
]

You may also like...

Leave a Reply