Can not access env.GITHUB_TOKEN in event handler
For some reason i can get my git hub token inside of the function i have done other debugging and it does work outside of the function. Normally i ask AI and it is pretty good at fixing my problems, Ive searched on here and online and i see where people have has problems similar but i can not get it fixed. here a paste bin of the cloud flare worker. if I hardcode the api key for testing it works just fine. https://pastebin.com/hUDWfrUH
Pastebin
Cloudflare Worker - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
4 Replies
Service worker format doesn't use env
It'd just be GITHUB_TOKEN
hmm, I tried to remove .env no luck, I just don't understand how i can run export default {
async fetch(request, env, ctx) {
return new Response(
API host: ${env.GITHUB_TOKEN}
);
}
} and it will log the correct one but the seccond i enter the event handler there is nothingbecause export default is module syntax
addEventListener is service worker syntax
they both handle envs differently
should just be that in service worker
If anyone else has ran into this please let me know. When I do what is listed above it says error fetching commit SHA: Bad Creditials. And the secrete is the exact same as if I paste it as plain text in the code