django 解决跨域问题
作者:互联网
1、下载插件:
pip install django-cors-headers
2、在settings.py 中添加app:
'corsheaders'
3、在settings.py 中添加中间件:
'corsheaders.middleware.CorsMiddleware'
4、在settings.py 中配置允许跨站访问本站的地址:
CORS_ORIGIN_WHITELIST = ['http://localhost:8080']
5、在settings.py 中配置ALLOWED_HOSTS:
ALLOWED_HOSTS = ["192.168.78.241", "127.0.0.1"]
跨域详解:
https://github.com/adamchainz/django-cors-headers/blob/main/README.rst
标签:corsheaders,跨域,settings,py,django,HOSTS,ALLOWED,解决 来源: https://www.cnblogs.com/yanlin-10/p/15749280.html