You've already forked AstralRinth
forked from didirus/AstralRinth
fix: vite dev server cf workers compatibility (#5080)
This commit is contained in:
@@ -8,7 +8,8 @@ async function getRateLimitKey(config) {
|
|||||||
if (!rateLimitKeyPromise) {
|
if (!rateLimitKeyPromise) {
|
||||||
rateLimitKeyPromise = (async () => {
|
rateLimitKeyPromise = (async () => {
|
||||||
try {
|
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()
|
return await env.RATE_LIMIT_IGNORE_KEY?.get()
|
||||||
} catch {
|
} catch {
|
||||||
return undefined
|
return undefined
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ import type { Ref } from 'vue'
|
|||||||
|
|
||||||
async function getRateLimitKeyFromSecretsStore(): Promise<string | undefined> {
|
async function getRateLimitKeyFromSecretsStore(): Promise<string | undefined> {
|
||||||
try {
|
try {
|
||||||
// @ts-expect-error only avail in workers env
|
const mod = 'cloudflare:workers'
|
||||||
const { env } = await import('cloudflare:workers')
|
const { env } = await import(/* @vite-ignore */ mod)
|
||||||
return await env.RATE_LIMIT_IGNORE_KEY?.get()
|
return await env.RATE_LIMIT_IGNORE_KEY?.get()
|
||||||
} catch {
|
} catch {
|
||||||
// Not running in Cloudflare Workers environment
|
// Not running in Cloudflare Workers environment
|
||||||
|
|||||||
Reference in New Issue
Block a user