标签:none host code outline www. mon localhost flow local
1.pip install django-cors-headers
2.添加应用
INSTALLED_APPS = (
…
)
3.中间层设置
MIDDLEWARE = [
]
4.添加白名单
(在这里添加后端的ip)
CORS_ORIGIN_WHITELIST = (
‘127.0.0.1:8080’,
‘localhost:8080’,
‘www.meiduo.site:8080’
)
CORS_ALLOW_CREDENTIALS = True # 允许携带cookie
5.设置allowed_hosts
允许所有主机访问 ‘*’
ALLOWED_HOSTS = [‘*’]
标签:none host code outline www. mon localhost flow local
原文地址:https://www.cnblogs.com/zhangtq/p/9728735.html