tymon
CDCloudflare Developers
•Created by tymon on 10/21/2024 in #general-help
Cache sveltekit site with cloudflare cache rule
Hi cloudflare team,
Are there a guild to cache svletekit site with cloudflare.
i have using cf cache but it not work right. ( using cache rule hostname equa "/"
Sveltekit using SSR, and user don't have to reload all page when click new link. => When using with CF (cloudflare) cache, when user click on link slug and the new slug don't show any content. and the site not work anymore, so user have to refresh (f5) brower (mean: reload all pae) and content of slug appear. So what is the right way to cache sveltekit site cloudflare?
1 replies
CDCloudflare Developers
•Created by tymon on 3/5/2024 in #pages-help
sveltekit api fetch from frontend not work
i doing follow this video: https://www.youtube.com/watch?v=qlmDj7q2x0c&t=742s
But work with deploy on vps, not with cf pages.
in
component
import to +page.svelte
i fetch like this:
const checklink = async (id: number) => {
try {
const testLink = await fetch(
/api/checkLink/${id})
return await testLink.json()
} catch (error) {
throw error
}
}
In folder api/checkLink/[id]/+server.ts
export const GET = async ({ params }) => {
const checkLink = async (id: string) => {
try {
const testLink = await fetch(
https://doaminlink.../${id}`)
if (testLink.ok) {
return https://domainlink/${id}
}
return https://linkb/${id}
} catch (error) {
throw error
}
}
return new Response(JSON.stringify(await checkLink(params.id)));
}`2 replies