-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enabling customization of allow-header with CORs. #3365
Comments
in main.go: rest.MustNewServer(c.RestConf, rest.WithCors) |
用了这个, 但是框架是设置了默认的 allowHeadersVal = "Content-Type, Origin, X-CSRF-Token, Authorization, AccessToken, Token, Range" 。 所以如果前端请求带上了不符合的header比如 X-Requested-With: XMLHttpRequest,就会报跨域问题 |
而且我觉得项目中自定义header 也是一个普遍的需求, 所以框架不应该限制我们只能传 allowHeadersVal = "Content-Type, Origin, X-CSRF-Token, Authorization, AccessToken, Token, Range" 这里面的值 |
我这也遇到同样问题 |
I also encountered the same problem here |
我遇到过 但是解决了 自定义跨域处理 func cors(header http.Header) { |
我这边cors跨域,发现是在浏览器发起options时,自定义的header字段没有在Access-Control-Allow-Headers中,我使用的版本比较老,是v1.3.4,一开始我daerfy的方案使用,将设置的header在这里的middlewareFn注入 func notAllowed(w http.ResponseWriter) { |
Use |
The feature is supported in the latest releases. |
目前项目中遇到了一个问题,前端组件使用ant-design-vue 的上传组件进行文件上传时会自动带上 X-Requested-With:
XMLHttpRequest。 但是go-zero的 allowHeadersVal 里面并没有这个参数。所以会导致前端提示跨域问题。 我个人认为go-zero组件不应该写死allow-header。应该开放一个方法或者配置让我们可以自由设置 allowHeadersVal。 虽然可以通过nginx进行代理,但是当个人本地同时开发前端和后端时,一般是直接启动服务,并不会去进行nginx的相关配置。所以就会导致前后端切换开发很麻烦。希望官方能支持自定义设置header
The text was updated successfully, but these errors were encountered: