Skip to content

Instantly share code, notes, and snippets.

@fronzec
Last active September 10, 2018 13:49
Show Gist options
  • Select an option

  • Save fronzec/9098d57e3f1b36aeabd5c4927eafa90f to your computer and use it in GitHub Desktop.

Select an option

Save fronzec/9098d57e3f1b36aeabd5c4927eafa90f to your computer and use it in GitHub Desktop.
Custom cors Middleware Django
# -*- coding:utf-8 -*-
# Put this file under <your_app>/middleware/cors.py
# Edit your setting.py
from django.http import HttpResponse
from django.utils.deprecation import MiddlewareMixin
class CorsMiddleware(MiddlewareMixin):
def process_response(self, request, response):
response["Acces-Control-Allow-Origin"] = "*"
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment