zoukankan
html css js c++ java
django 跨域
目录
解决办法
1. 安装一个django cor包
2. 在 项目/setting.py中, 新增
3. 添加白名单:在白名单内的所有域名都可以访问
1
|
0
解决办法
通过django中间件进行添加跨域头
1
|
1
1. 安装一个django cor包
pip install django-cors-headers
1
|
2
2. 在 项目/setting.py中, 新增
INSTALLED_APPS = [ ...
'corsheaders', ... ]
MIDDLEWARE = ( ...
'corsheaders.middleware.CorsMiddleware',
# cors-headers的中间件CorsMiddleware在注册时必须放在django-common中间件的前一个
'django.middleware.common.CommonMiddleware', ... )
1
|
3
3. 添加白名单:在白名单内的所有域名都可以访问
# CORS
CORS_ORIGIN_WHITELIST = (
'http:127.0.0.1:8080',
'http:localhost:8080',
'www.xxx.site:8080', ) CORS_ALLOW_CREDENTIALS = True
# 允许携带cookie
查看全文
相关阅读:
RTB业务知识2-Open-RTB全景
常见的选择<数据源协议,委托协议>(IOS发展)
PHP高级编程SPL
matlab 基础知识class < superclass_name
Codeforces Round #FF (Div. 2)
HDU 5063 Operation the Sequence
新版本MenuDemo——使用Duilib模拟Windows本机菜单
Codeforces 458A Golden System
Arcgis for Javascript实现图
[Angular2Fire] Firebase auth (Google, Github)
原文地址:https://www.cnblogs.com/guofeng-1016/p/14836022.html
最新文章
super-pow
sum-of-two-integers
largest-divisible-subset
valid-perfect-square
water-and-jug-problem
max-sum-of-sub-matrix-no-larger-than-k
矩阵求和及Kadane算法
count-numbers-with-unique-digits
design-twitter
properties 文件的中文转ASCII
热门文章
强大的Http监控工具Fidder
Objective-C中的SEL、IMP和Class类型
hadoop部署、启动全套过程
hdu3999The order of a Tree (二叉平衡树(AVL))
好消息:8月25日广州嵌入式Linux开发免费项目约定你
第二代map-reduce架构YARN解析
shell脚本调试
并查集找连通分量的个数
项目.c文件和.h文件关系
2014全球移动互联网大会召开
Copyright © 2011-2022 走看看