Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

chore: update get request origin

Stevenc1da87a81916
diff --git a/server/route/api/v2/auth_service.go b/server/route/api/v2/auth_service.go
index 40d37b287..e7ea805dc 100644
--- a/server/route/api/v2/auth_service.go
+++ b/server/route/api/v2/auth_service.go
@@ -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")
+ }
+ 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, "Secure")
} else {