Skip to content

Commit 1cd6153

Browse files
committed
fix: Make cookies host-only in dev mode for test compatibility
1 parent 6c8b5f4 commit 1cd6153

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

model/session/session.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,12 @@ func CookieName(i *instance.Instance) string {
180180
// subdomains, we need to put it one level higher (eg .mycozy.cloud instead of
181181
// .example.mycozy.cloud) to make the cookie available when the user visits
182182
// their apps.
183+
// In development mode, returns empty string to make cookies host-only,
184+
// which allows tests to work with localhost.
183185
func CookieDomain(i *instance.Instance) string {
186+
if build.IsDevRelease() {
187+
return ""
188+
}
184189
domain := i.ContextualDomain()
185190
if config.GetConfig().Subdomains == config.FlatSubdomains {
186191
parts := strings.SplitN(domain, ".", 2)

web/shortcuts/shortcuts_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func TestShortcuts(t *testing.T) {
7171

7272
cozyMeta := attrs.Value("cozyMetadata").Object()
7373
cozyMeta.Value("createdAt").String().DateTime(time.RFC3339)
74-
cozyMeta.Value("createdOn").String().Contains("https://testshortcuts_")
74+
cozyMeta.Value("createdOn").String().Contains("https://testshortcuts-")
7575

7676
target := attrs.Value("metadata").Object().Value("target").Object()
7777
target.ValueEqual("app", "photos")

0 commit comments

Comments
 (0)