mirror of
https://github.com/usememos/memos.git
synced 2025-03-07 02:53:29 +08:00
chore: update get request origin
This commit is contained in:
parent
3b089eeae3
commit
c1da87a819
1 changed files with 10 additions and 4 deletions
|
@ -248,11 +248,17 @@ func (s *APIV2Service) buildAccessTokenCookie(ctx context.Context, accessToken s
|
|||
} else {
|
||||
attrs = append(attrs, "Expires="+expireTime.Format(time.RFC1123))
|
||||
}
|
||||
workspaceGeneralSetting, err := s.Store.GetWorkspaceGeneralSetting(ctx)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "failed to get workspace setting")
|
||||
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
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, "Secure")
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue