Can't import my env in my Function in Astro
Hello, I'm currently working on an Astro project and I'm trying to hide my API key using environment variables or secrets. However, when I attempt to import them into my code after publishing the page, it shows the error message:
I'm using Cloudflare SSR in a hybrid setup.
Here's the code from my function:
If anybody has a solution to this issue, it would really help me out.
7 Replies
Have you defined the
TEST
vairable, either on the dashboard or in your wrangler.toml
?Yes in the dashboard
Wait, is
TEST
a KV Namespace?Yes, I've defined it in my KV namespaces Binding looking for my KV namespace
I was trying like this cuz i can't import the variable that i've set up in my Worker & Pages section
Try this:
Might also be
context.locals.runtime.env.TEST
For the first Version i've got this error :
And with the :
It worked ! Thx so much !
Yeah, the frameworks like doing their own thing