Skip to content

Commit 6d8c647

Browse files
fix: read announcement id from live URL instead of serialized SSR data
The announcement id was extracted in the universal load function and serialized into SSR HTML. When a CDN cached one announcement URL and served it for another, the baked-in id caused the wrong announcement to render on direct page load. Now selectedId derives from page.url (the actual browser URL) rather than data.id, making the page immune to CDN cache cross-contamination.
1 parent 0b75d6c commit 6d8c647

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

src/routes/announcements/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
let { data } = $props();
2121
22-
let selectedId = $derived(data.id);
22+
let selectedId = $derived(page.url.searchParams.get('id'));
2323
2424
const initialParams = browser
2525
? new URL(window.location.href).searchParams

src/routes/announcements/+page.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import type { PageLoad } from './$types';
22

3-
export const load: PageLoad = ({ url, data }) => {
4-
const id = url.searchParams.get('id');
3+
export const load: PageLoad = ({ data }) => {
54
return {
6-
id,
75
announcements: data.announcements
86
};
97
};

0 commit comments

Comments
 (0)