-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Cloudflare Workers #78
base: main
Are you sure you want to change the base?
Conversation
8d664b2
to
99a60b8
Compare
Confirmed this addresses the Cloudflare deployment issue. @hmnd I noticed Cloudflare Pages doesn't like when |
@vhscom Rich Harris said in a video that a better env variable story is on the roadmap--so a workaround like this may be sufficient for now. Github Pages supports specifying environmental variables via the web UI. Maybe a solution is to only use
|
@Dan6erbond would it be possible to merge this please? It would unblock anyone using Cloudflare |
Sorry for not responding to this sooner. For Cloudflare Workers Sites, env variables are provided as global variables. The way I would handle that is wrap the dotenv import in an if block, checking whether you're in a dev environment. For Cloudflare Pages, env variables are provided in Anyway, I don't really think that question is relevant to whether this PR can be merged, so would be awesome if it could be ;). |
Would love to see this merged, planning to push out a PoC w/ SvelteKit and Auth and this looks like it'll be a blocker for that (planning to push to either vercel edge or cloudflare pages). Worth noting this will fix a bunch of other current and future edge providers too. (See https://wintercg.org/ for more deets on that) |
@RichiCoder1 if it helps, I have this PR published at @icewolf/[email protected] |
I've also rolled this change into a fork published to NPM. If you're using PMPM you can adjust the module source for |
@hmnd Thanks! I'm getting a Cloudflare "Error 1101" "Worker threw exception" on Cloudflare Pages when redirecting back to the site at |
In the Workers UI, there's a way to live stream worker |
Just checked. Unfortunately log streaming is only available for standard workers. When deploying via Cloudflare Pages, Svelte Kit's workers don't appear under Workers tab in the Cloudflare Dash, so log streaming isn't available. |
Is this the how you all do env vars in production? Maybe this is where I'm messing up. I have them specified in Cloudflare env settings, in the same way as providers: [
new GitHubOAuth2Provider({
clientId: process.env.GITHUB_OAUTH_CLIENT_ID ?? import.meta.env.VITE_GITHUB_OAUTH_CLIENT_ID,
clientSecret:
process.env.GITHUB_OAUTH_CLIENT_SECRET ?? import.meta.env.VITE_GITHUB_OAUTH_CLIENT_SECRET,
profile(profile) {
return { ...profile, provider: 'github' };
}
})
], |
Ahh, that might be it! Cloudflare variables work different than traditional node environments. Details here: https://developers.cloudflare.com/workers/platform/environment-variables/. TL;DR: In cloudflare, they become globals and you reference them like |
No luck; thanks though.
@hmnd What's the proper way to consume your fork in my // package.json
"devDependencies": {
"@icewolf/sk-auth": "^0.4.1-bleeding.7",
//...
} // appAuth.js
import { SvelteKitAuth } from '@icewolf/sk-auth';
import { GitHubOAuth2Provider } from '@icewolf/sk-auth/providers'; |
99a60b8
to
9ccbca9
Compare
fixes #42
Buffer
.