当前位置:网站首页>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)
边栏推荐
- Question bank and answers of special operation certificate examination for main principals of hazardous chemical business units in 2022
- Broyage · fusion | savoir que le site officiel de chuangyu mobile end est en ligne et commencer le voyage de sécurité numérique!
- Talk about the understanding of fault tolerance mechanism and state consistency in Flink framework
- 运算符、、
- Go语言-1-开发环境配置
- NAS与SAN
- App各大应用商店/应用市场网址汇总
- Taro进阶
- vite//
- Pull up loading principle
猜你喜欢

2022年T电梯修理操作证考试题及答案

Question bank and answers of special operation certificate examination for main principals of hazardous chemical business units in 2022

Go语言-1-开发环境配置

Broyage · fusion | savoir que le site officiel de chuangyu mobile end est en ligne et commencer le voyage de sécurité numérique!

Go-3-the first go program

磨礪·聚變|知道創宇移動端官網煥新上線,開啟數字安全之旅!

爬虫(9) - Scrapy框架(1) | Scrapy 异步网络爬虫框架

Comparative learning in the period of "arms race"

关于vray 5.2的使用(自研笔记)(二)

Go language-1-development environment configuration
随机推荐
2022 Pengcheng cup Web
2022 t elevator repair operation certificate examination questions and answers
小红书自研KV存储架构如何实现万亿量级存储与跨云多活
When using gbase 8C database, an error is reported: 80000502, cluster:%s is busy. What's going on?
Do you really understand the things about "prototype"? [part I]
图片懒加载的方案
Review the whole process of the 5th Polkadot Hackathon entrepreneurship competition, and uncover the secrets of the winning projects!
PWA (Progressive Web App)
Process control
LSTM applied to MNIST dataset classification (compared with CNN)
SQL Server monitoring statistics blocking script information
Go language learning notes - first acquaintance with go language
2022年危险化学品生产单位安全生产管理人员特种作业证考试题库模拟考试平台操作
vite//
go语言学习笔记-初识Go语言
iframe
C语言活期储蓄账户管理系统
谈谈对Flink框架中容错机制及状态的一致性的理解
Scaffold development foundation
分享.NET 轻量级的ORM