How to access env variables?
I set one using wrangler and now I can't access it? I couldn't even find a way to access it in the docs help me.
19 Replies
Adapter Helper - Hono
Ultrafast web framework for Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, Node.js, and others. Fast, but not only fast.
https://github.com/honojs/hono/issues/799#issuecomment-1990977003
Can you check this? I'm struggling to figure it out.
GitHub
.env files not loaded into c.env · Issue #799 · honojs/hono
I found the .env files are not loaded into c.env: Runtime: Bun 0.4.0 // index.ts import { Hono } from 'hono' interface Bindings { API_KEY: string API_SECRET: string } const app = new Hono&l...
You are extracting
GEMINI_AI
, but then trying to use GEMINI_API
I corrected it
Is there a way to use it wihout using (c)?
The thread it corrected, read one it GEMINI_API
No, you are supposed to use
c
Environment Variables are not accessible in a global context
Ok, so in this code I want to access the env outsite the get? so ho do I do that?
You don't. Environment variables are only defined within the
get
Or whatever other handler functions you defineOk, so I can do this right?
let output = await run(c);
??
Like I need the value of env in my run()Yes, you can do that
Am I doing it right, it's working, but sometimes give internal server error.
Looks right to me. What does the error show?
Just
internal server error
is there a console on on Cloudflare, let me check
Now, After the second deployment the errors vanished now no more errors.Does it work locally?
Yes, it working fine now.
Just a little slow
I will enable streaming now, so it gives words one by one.
Let's see how can I do that
I didn't had cors in it, so was working with my IP only. Couldn't open the site from anyohter place
I have this code, and I can't access it outside my home network. I don't know why
/v1 route is working but not the / route
ANS: it's not wokers it GEMINI API: giving this output.
"Error: [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1/models/gemini-pro:generateContent: [400 Bad Request] User location is not supported for the API use."
That sounds like an issue from Google’s end
They might have locked their APIs down to certain locations by IP
It works with my HOME network but not with the mobile
LOL What a pain.
Need to find some other free LLM api
Nope, finally I found the issue was with the way CloudFlare handled the reqeust, since Google is geo-blocking in some countries, When I was using fiber internet it worked, but when I switched to mobile internet I don't know how cloudflare did it's routing, but it might have went to some geo-blocked country like EU etc.
But the logs always showed some IP from India. Using the VPN worked.