fix: vite dev server cf workers compatibility (#5080)

This commit is contained in:
Michael H.
2026-01-10 15:11:00 +01:00
committed by GitHub
parent b0f1266a8b
commit 0b60060f65
2 changed files with 4 additions and 3 deletions

View File

@@ -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

View File

@@ -15,8 +15,8 @@ import type { Ref } from 'vue'
async function getRateLimitKeyFromSecretsStore(): Promise<string | undefined> {
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