11import process from 'node:process'
2- import { defineNuxtModule } from 'nuxt/kit'
2+ import { defineNuxtModule , useRuntimeConfig } from 'nuxt/kit'
33import { provider } from 'std-env'
44
55// Storage key for fetch cache - must match shared/utils/fetch-cache-config.ts
@@ -14,9 +14,17 @@ export default defineNuxtModule({
1414 return
1515 }
1616
17+ const config = useRuntimeConfig ( )
18+
1719 nuxt . hook ( 'nitro:config' , nitroConfig => {
1820 nitroConfig . storage = nitroConfig . storage || { }
1921
22+ const upstash = {
23+ driver : 'upstash' as const ,
24+ url : config . upstash . redisRestUrl ,
25+ token : config . upstash . redisRestToken ,
26+ }
27+
2028 // Main cache storage (for defineCachedFunction, etc.)
2129 nitroConfig . storage . cache = {
2230 ...nitroConfig . storage . cache ,
@@ -30,9 +38,8 @@ export default defineNuxtModule({
3038 }
3139
3240 const env = process . env . VERCEL_ENV
33- nitroConfig . storage . atproto = {
34- driver : env === 'production' ? 'vercel-kv' : 'vercel-runtime-cache' ,
35- }
41+ nitroConfig . storage . atproto =
42+ env === 'production' ? upstash : { driver : 'vercel-runtime-cache' }
3643 } )
3744 } ,
3845} )
0 commit comments