From 0b60060f6574854dbe0209ed503db3df66a9d6b2 Mon Sep 17 00:00:00 2001 From: "Michael H." Date: Sat, 10 Jan 2026 15:11:00 +0100 Subject: [PATCH] fix: vite dev server cf workers compatibility (#5080) --- apps/frontend/src/composables/fetch.js | 3 ++- apps/frontend/src/helpers/api.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/frontend/src/composables/fetch.js b/apps/frontend/src/composables/fetch.js index 80d619cd..4b523176 100644 --- a/apps/frontend/src/composables/fetch.js +++ b/apps/frontend/src/composables/fetch.js @@ -8,7 +8,8 @@ async function getRateLimitKey(config) { if (!rateLimitKeyPromise) { rateLimitKeyPromise = (async () => { try { - const { env } = await import('cloudflare:workers') + const mod = 'cloudflare:workers' + const { env } = await import(/* @vite-ignore */ mod) return await env.RATE_LIMIT_IGNORE_KEY?.get() } catch { return undefined diff --git a/apps/frontend/src/helpers/api.ts b/apps/frontend/src/helpers/api.ts index 796d8f1e..5b49bcf3 100644 --- a/apps/frontend/src/helpers/api.ts +++ b/apps/frontend/src/helpers/api.ts @@ -15,8 +15,8 @@ import type { Ref } from 'vue' async function getRateLimitKeyFromSecretsStore(): Promise { try { - // @ts-expect-error only avail in workers env - const { env } = await import('cloudflare:workers') + const mod = 'cloudflare:workers' + const { env } = await import(/* @vite-ignore */ mod) return await env.RATE_LIMIT_IGNORE_KEY?.get() } catch { // Not running in Cloudflare Workers environment