Skip to content

Commit f6f44c9

Browse files
fix: send JSON content type for inbox sync
The CSRF guard requires application/json on mutation requests, including zero-body endpoints. The inbox sync store now sends that header so the sync button triggers the background notification refresh instead of receiving 415. Verified with:\n- cd packages/ui && bun test src/stores/notifications.test.ts\n- cd packages/ui && bun run typecheck\n- git diff --check
1 parent d82aa4f commit f6f44c9

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

packages/ui/src/stores/notifications.svelte.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ export function createNotificationsStore(
200200
try {
201201
const { error: requestError } = await apiClient.POST(
202202
"/notifications/sync",
203+
{ headers: { "Content-Type": "application/json" } },
203204
);
204205
if (requestError) {
205206
throw new Error(apiErrorMessage(requestError, "failed to sync inbox"));

packages/ui/src/stores/notifications.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ describe("createNotificationsStore", () => {
153153
await store.triggerSync();
154154
for (let i = 0; i < 100; i++) await Promise.resolve();
155155

156-
expect(post).toHaveBeenCalledWith("/notifications/sync");
156+
expect(post).toHaveBeenCalledWith("/notifications/sync", {
157+
headers: { "Content-Type": "application/json" },
158+
});
157159
expect(get).toHaveBeenCalledTimes(5);
158160
expect(delays).toEqual([500, 1_500, 3_000, 5_000]);
159161
} finally {

0 commit comments

Comments
 (0)