跨域demo没有生效
godsoul opened this issue · 2 comments
godsoul commented
Describe the bug
运行 middleware/CORS 下代码,返回的请求头还是没有带跨域的,option请求也会返回404
Hertz version:
v0.1.0
Environment:
GOVERSION="go1.18.3"
Additional context
h.Use(cors.New(cors.Config{
AllowOrigins: []string{"*"}, // Allowed domains, need to bring schema
AllowMethods: []string{"*"}, // Allowed request methods
AllowHeaders: []string{"*"}, // Allowed request headers
ExposeHeaders: []string{"Content-Length"}, // Request headers allowed in the upload_file
AllowCredentials: true, // Whether cookies are attached
MaxAge: 12 * time.Hour, // Maximum length of upload_file-side cache preflash requests (seconds)
}))
li-jin-gou commented
可以 debug
自查一下代码并看下 https://www.cloudwego.io/docs/hertz/tutorials/basic-feature/middleware/cors/ 哈 @godsoul
godsoul commented
必须发带Origin的头