django内部csrf post提交数据解决

https://www.cnblogs.com/iiiiiher/articles/9164940.html

前端写了个页面,里面$.post发现403错误. 需要注释下

前后端联调的跨域问题

前端可能是127.0.0.1:3000 后端127.0.0.1:8080

导致前端不能正常访问

https://github.com/ottoyiu/django-cors-headers

安装配置

pip install django-cors-headers

INSTALLED_APPS = (
...
'corsheaders',
...
) MIDDLEWARE = [ # Or MIDDLEWARE_CLASSES on Django < 1.10
...
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
...
]

配置

- 全局设置为true
CORS_ORIGIN_ALLOW_ALL = True
- 指定白名单
CORS_ORIGIN_WHITELIST = (
'google.com',
'hostname.example.com',
'localhost:8000',
'127.0.0.1:9000'
)
- reg匹配域名

- 限制方法

最新文章

  1. 简单排序,C# 直接使用 List。
  2. Spark Streaming消费Kafka Direct方式数据零丢失实现
  3. Halcon 10.0:Sample 分割边缘拟合圆Circles.hdev
  4. ubuntu 命令行软件包管理
  5. 解决Socket.IO在IE8下触发disconnect时间过长
  6. UIViewController中各方法调用顺序及功能详解
  7. less学习-语法(二)
  8. quartz简单实现
  9. photoshopcs5 win7安装报错的解决
  10. 3 Sum Closest 解答
  11. Jar包转成Dll的方式(带嵌套的jar也能做) (转)
  12. ubuntu环境下lnmp环境搭建(1)之Mysql
  13. nodejs爬虫笔记(一)---request与cheerio等模块的应用
  14. luogu P1602 Sramoc问题
  15. numpy的random模块
  16. appium使用错误集合
  17. SpringMVC异常处理注解@ExceptionHandler@ControllerAdvice@ResponseStatus
  18. Android7.0对dlopen的改变——读取私有.so结果变化
  19. [原]IOS 后台发送邮件
  20. SOALog

热门文章

  1. 史上最简洁的UITableView Sections 展示包含NSDicionary 的NSArray
  2. 关于linux Centos 7一个网卡配置多个IP的方法
  3. iOS动画篇:核心动画
  4. python 读取配置文件方法
  5. day_5.11 py main
  6. 引用了System.Configuration命名空间,却找不到ConfigurationManager类
  7. J - Vertical Histogram(1.5.7)
  8. DB2 性能分析工具介绍:Event Monitor 篇(转)
  9. 2018ACM-ICPC南京区域赛M---Mediocre String Problem【exKMP】【Manacher】
  10. win server 2008添加磁盘-脱机转换为联机状态方法