You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
flyapps/fir_ser/api/utils/middlewares.py

23 lines
712 B

import logging
from django.utils.deprecation import MiddlewareMixin
3 years ago
logger = logging.getLogger(__name__)
4 years ago
class CorsMiddleWare(MiddlewareMixin):
4 years ago
def process_response(self, request, response):
if request.method == "OPTIONS":
response["Access-Control-Allow-Methods"] = "GET,POST,DELETE,PUT"
response["Access-Control-Allow-Headers"] = "Content-Type,AUTHORIZATION,x-token"
4 years ago
try:
response["Access-Control-Allow-Origin"] = request.META.get("HTTP_ORIGIN")
response["Access-Control-Allow-Credentials"] = 'true'
3 years ago
# response["Cache-Control"] = "no-cache"
4 years ago
except Exception as e:
logger.error(e)
4 years ago
return response