KWAC
KWAC
Explore posts from servers
NNuxt
Created by KWAC on 7/28/2024 in #❓・help
nuxt 3 + cloudfare D1 problems with env.d.ts file
I'm using nuxt 3 with cloudfare D1, but I have encountered some problems. It seems that it cannot read env.d.ts file I have created. I'm getting this error:
500 Cannot read properties of undefined (reading 'env')
500 Cannot read properties of undefined (reading 'env')
I used this repo: https://github.com/tlebeitsuk/nuxt-cloudflare-lucia My configured env.d.ts file:
import { CfProperties, Request, ExecutionContext, KVNamespace, D1Database } from '@cloudflare/workers-types';

declare module 'h3' {
interface H3EventContext {
cf: CfProperties,
cloudflare: {
request: Request,
env: {
MY_KV: KVNamespace,
DB: D1Database,
}
context: ExecutionContext,
};
}
}
import { CfProperties, Request, ExecutionContext, KVNamespace, D1Database } from '@cloudflare/workers-types';

declare module 'h3' {
interface H3EventContext {
cf: CfProperties,
cloudflare: {
request: Request,
env: {
MY_KV: KVNamespace,
DB: D1Database,
}
context: ExecutionContext,
};
}
}
22 replies