当前位置:网站首页>Beego cross domain problem solution - successful trial
Beego cross domain problem solution - successful trial
2022-07-05 10:52:00 【Lookno construction】
filter.go
var success = []byte("SUPPORT OPTIONS")
var corsFunc = func(ctx *context.Context) {
origin := ctx.Input.Header("Origin")
ctx.Output.Header("Access-Control-Allow-Methods", "OPTIONS,DELETE,POST,GET,PUT,PATCH")
ctx.Output.Header("Access-Control-Max-Age", "3600")
ctx.Output.Header("Access-Control-Allow-Headers", "X-Custom-Header,accept,Content-Type,Access-Token")
ctx.Output.Header("Access-Control-Allow-Credentials", "true")
ctx.Output.Header("Access-Control-Allow-Origin", origin)
if ctx.Input.Method() == http.MethodOptions {
// options request , return 200
ctx.Output.SetStatus(http.StatusOK)
_ = ctx.Output.Body(success)
}
}
func init() {
beego.InsertFilter("/*", beego.BeforeRouter, corsFunc)
}
stay app.conf Add
copyrequestbody = true
POST The data is in this.Ctx.Input.RequestBody In order to get
var num1 map[string]interface{
}
err := json.Unmarshal(this.Ctx.Input.RequestBody,&num1)
边栏推荐
- 【DNS】“Can‘t resolve host“ as non-root user, but works fine as root
- 流程控制、
- regular expression
- When using gbase 8C database, an error is reported: 80000502, cluster:%s is busy. What's going on?
- Go-2-Vim IDE常用功能
- App各大应用商店/应用市场网址汇总
- 正则表达式
- Talk about the understanding of fault tolerance mechanism and state consistency in Flink framework
- Nuxt//
- Web Components
猜你喜欢
Broyage · fusion | savoir que le site officiel de chuangyu mobile end est en ligne et commencer le voyage de sécurité numérique!
Based on shengteng AI Yisa technology, it launched a full target structured solution for video images, reaching the industry-leading level
32: Chapter 3: development of pass service: 15: Browser storage media, introduction; (cookie,Session Storage,Local Storage)
C language QQ chat room small project [complete source code]
LSTM应用于MNIST数据集分类(与CNN做对比)
微信核酸检测预约小程序系统毕业设计毕设(6)开题答辩PPT
Go-3-第一个Go程序
谈谈对Flink框架中容错机制及状态的一致性的理解
关于vray5.2怎么关闭日志窗口
微信核酸检测预约小程序系统毕业设计毕设(8)毕业设计论文模板
随机推荐
Honing · fusion | know that the official website of Chuangyu mobile terminal is newly launched, and start the journey of digital security!
matlab cov函数详解
Advanced scaffold development
Applet framework taro
谈谈对Flink框架中容错机制及状态的一致性的理解
Talk about the understanding of fault tolerance mechanism and state consistency in Flink framework
Solution to the length of flex4 and Flex3 combox drop-down box
2022鹏城杯web
2021年山东省赛题库题目抓包
关于 “原型” 的那些事你真的理解了吗?【上篇】
关于vray 5.2的使用(自研笔记)(二)
5g NR system architecture
脚手架开发进阶
双向RNN与堆叠的双向RNN
PWA (Progressive Web App)
Go language-1-development environment configuration
String
【SWT组件】内容滚动组件 ScrolledComposite
微信核酸检测预约小程序系统毕业设计毕设(8)毕业设计论文模板
九度 1480:最大上升子序列和(动态规划思想求最值)