Skip to content

Commit

Permalink
fix(net/ghttp): get origin through referer (#3990)
Browse files Browse the repository at this point in the history
  • Loading branch information
yzy613 authored Dec 1, 2024
1 parent 16d73b5 commit e572ed0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/ghttp/ghttp_response_cors.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ func (r *Response) DefaultCORSOptions() CORSOptions {
if origin := r.Request.Header.Get("Origin"); origin != "" {
options.AllowOrigin = origin
} else if referer := r.Request.Referer(); referer != "" {
if p := gstr.PosR(referer, "/", 6); p != -1 {
options.AllowOrigin = referer[:p]
if ref, err := url.Parse(referer); err == nil {
options.AllowOrigin = ref.Scheme + "://" + ref.Host
} else {
options.AllowOrigin = referer
}
Expand Down

0 comments on commit e572ed0

Please sign in to comment.