Commit c1da87a8 authored by Steven's avatar Steven

chore: update get request origin

parent 3b089eea
...@@ -248,11 +248,17 @@ func (s *APIV2Service) buildAccessTokenCookie(ctx context.Context, accessToken s ...@@ -248,11 +248,17 @@ func (s *APIV2Service) buildAccessTokenCookie(ctx context.Context, accessToken s
} else { } else {
attrs = append(attrs, "Expires="+expireTime.Format(time.RFC1123)) attrs = append(attrs, "Expires="+expireTime.Format(time.RFC1123))
} }
workspaceGeneralSetting, err := s.Store.GetWorkspaceGeneralSetting(ctx)
if err != nil { md, ok := metadata.FromIncomingContext(ctx)
return "", errors.Wrap(err, "failed to get workspace setting") if !ok {
return "", errors.New("failed to get metadata from context")
}
var origin string
for _, v := range md.Get("origin") {
origin = v
} }
if strings.HasPrefix(workspaceGeneralSetting.InstanceUrl, "https://") { isHTTPS := strings.HasPrefix(origin, "https://")
if isHTTPS {
attrs = append(attrs, "SameSite=None") attrs = append(attrs, "SameSite=None")
attrs = append(attrs, "Secure") attrs = append(attrs, "Secure")
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment