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
查看全文
相关阅读:
sudo详解
Linux按照CPU、内存、磁盘IO、网络性能监测
基于kickstart定制自动化安装的linux镜像系统
基于busybox和LFS的linux系统定制
syslog及syslog-ng详解 日志服务器
yum报错
二进制程序及其依赖库的移植脚本
Linux 系统裁剪
linux 内核手动编译
linux rc.sysinit文件详解
原文地址:https://www.cnblogs.com/guofeng-1016/p/14836022.html
最新文章
系统调优之numa架构
Nginx架构的企业级应用
Linux 常见的trouble shooting故障排错
shell控制流结构笔记
iptables详解
最小化安装centos的init初始化脚本
shell脚本之lnmp的搭建
linux 强大的编辑器之vi
linux硬盘分区格式化及挂载
LAMMP架构的企业级应用
热门文章
SSH配置私钥登陆服务器
PHP 之 FastCGI 与 mod_php 详解
CentOS 6.3下源码安装LAMP(Linux+Apache+Mysql+Php)环境
LNMP(linux+nginx+mysql+php)服务器环境配置
mysql常用命令总结
我所了解的cgi(转)
HTTP协议详解
杀死僵尸进程的小脚本
linux ssh 使用深度解析(key登录详解)
linux(centos)下SVN服务器如何搭建
Copyright © 2011-2022 走看看