Skip to content

Commit 9191ce6

Browse files
committed
Improve session handling and sign-out in layout.liquid
Enhanced the signOut method to include error handling and set Content-Type header. Updated getSession to prevent caching by adding a timestamp and cache-control headers. Also fixed the npm dev script to use the correct command.
1 parent e9559fe commit 9191ce6

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"examples/*"
77
],
88
"scripts": {
9-
"dev": "npm run start:dev --workspace=@objectql/server",
9+
"dev": "npm run dev --workspace=@objectql/server",
1010
"start": "npm run start --workspace=@objectql/server",
1111
"build": "tsc -b && npm run build --workspaces",
1212
"test": "npm run test --workspaces",

packages/server/src/views/layout.liquid

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,25 @@
146146
return res.json();
147147
},
148148
async signOut() {
149-
await fetch(`${this.baseUrl}/sign-out`, { method: 'POST' });
149+
try {
150+
await fetch(`${this.baseUrl}/sign-out`, {
151+
method: 'POST',
152+
headers: {
153+
'Content-Type': 'application/json'
154+
}
155+
});
156+
} catch (e) {
157+
console.error("Sign out error:", e);
158+
}
150159
window.location.href = '/login';
151160
},
152161
async getSession() {
153-
const res = await fetch(`${this.baseUrl}/get-session`);
162+
const res = await fetch(`${this.baseUrl}/get-session?_t=${Date.now()}`, {
163+
headers: {
164+
'Cache-Control': 'no-store, no-cache, must-revalidate',
165+
'Pragma': 'no-cache'
166+
}
167+
});
154168
if (!res.ok) return null;
155169
return res.json();
156170
}

0 commit comments

Comments
 (0)