go-zero icon indicating copy to clipboard operation
go-zero copied to clipboard

go-zero api WithNotFoundHandler & WithNotAllowedHandler 未兼容 WithCustomCors & WithCors

Open smithyj opened this issue 2 years ago • 10 comments

在 go-zero 中对 NotFoundHandler & NotAllowedHandler 的这种情况进行了封装 image 正常可到达请求返回 Header 如下 image 但是在请求 NotFoundHandler & NotAllowedHandler 不存在的链接时,没有出现 Cors Header 头信息,这样就会导致前端跨域报错,然后整个开发体验会不是很友好 image

smithyj avatar Jun 14 '22 16:06 smithyj

@kevwan 目前我想到的有两种解决方案,一种是将用户注册的 Cors 在 NotFoundHandler & NotAllowedHandler 之前再运行一次,另外一种就是用户手动在自定义handler里面再处理一次 Cors,差不多跟下面类似 image 当然,最优雅的肯定是框架内部去解决这个问题

smithyj avatar Jun 14 '22 16:06 smithyj

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


I'll see if I can make a PR over the weekend. The implementation of this piece is really not elegant at the moment.

Issues-translate-bot avatar Jun 14 '22 16:06 Issues-translate-bot

#2023

smithyj avatar Jun 15 '22 14:06 smithyj

我有同样的问题

chowyu12 avatar Jun 24 '22 06:06 chowyu12

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


i have the same problem

Issues-translate-bot avatar Jun 24 '22 06:06 Issues-translate-bot

@chowyu12 跟踪下这个PR合并进度就好了,不知道万总会不会在下一个版本调整 #2023

smithyj avatar Jun 27 '22 09:06 smithyj

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@chowyu12 Just track the progress of this PR merge, I wonder if Wan will adjust it in the next version #2023

Issues-translate-bot avatar Jun 27 '22 09:06 Issues-translate-bot

@chowyu12 跟踪下这个PR合并进度就好了,不知道万总会不会在下一个版本调整 #2023

I think so.

kevwan avatar Jun 27 '22 15:06 kevwan

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@chowyu12 Just track the progress of this PR merge, I wonder if Wan will adjust it in the next version #2023

I think so.

Issues-translate-bot avatar Jun 27 '22 15:06 Issues-translate-bot

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Jul 28 '22 02:07 github-actions[bot]