-
安装
pip install django-cors-headers
-
添加应用
""" 'corsheaders', """
-
中间件设置
MIDDLEWARE = [ 'corsheaders.middleware.CorsMiddleware', ... ]
-
添加白名单
# CORS CORS_ORIGIN_WHITELIST = ( 'http://127.0.0.1:8080', 'http://localhost:8080', 'http://www.meiduo.site:8080', 'http://api.meiduo.site:8000' ) CORS_ALLOW_CREDENTIALS = True # 允许携带cookie
跨域
最新推荐文章于 2024-07-06 09:00:00 发布