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:
I used this repo: https://github.com/tlebeitsuk/nuxt-cloudflare-lucia
My configured env.d.ts file:
GitHub
GitHub - tlebeitsuk/nuxt-cloudflare-lucia: A demo using Nuxt, Cloud...
A demo using Nuxt, Cloudflare Pages, Cloudflare D1 database and Lucia for auth - tlebeitsuk/nuxt-cloudflare-lucia
12 Replies
And here is middleware->auth.ts
Specifically this part is responsible
am i doing something wrong
Hii, were you able to fix this error?
if i call my route directly, it returns data successfully, no idea why this would fail
eh unfortunately not, i'm still trying to figure out what could be wrong
this went away for me once i created a types folder and added env.d.ts
could you share a repo so i could take a look?
Mine's not public, but here's how the structure looks like
this basically worked for me
env.d.ts specifically needs to be in src->types folder? I thought i can paste this file in root folder of the project
if you have src set in nuxt config then it has to go inside src yes
that is what i believe lol
i am new to nuxt/vue as well so not sure
Okay
But looking at this
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,
};
}
}
am I declaring DB correctly?
And for MY_KV: KVNamespace is not needed in my case? As for now I only need D1
And for MY_KV: KVNamespace is not needed in my case? As for now I only need D1
that is how'd you declare normally when using cloudflare workers
so unless nitro does something with the variables, this should work
Also this randomly still appears for me
@Oreki Sorry for pinging
I now setup it correctly using command
I was missing some files like Also I had to downgrade wrangler version because newer one was broken.
My drizzle config looks like this:
My question is how to query and receive data from a table? Mine doesn't really work. I have two entries in that table. It shows status 200 but it doens't really print out that info from table
getdata.js
i don't really think nitro would have a db key in context?