mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: update get request origin
This commit is contained in:
@@ -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")
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(workspaceGeneralSetting.InstanceUrl, "https://") {
|
var origin string
|
||||||
|
for _, v := range md.Get("origin") {
|
||||||
|
origin = v
|
||||||
|
}
|
||||||
|
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 {
|
||||||
|
Reference in New Issue
Block a user