arcjet / arcjet-js

Arcjet JS SDKs. Rate limiting, bot protection, email verification & attack defense for Node.js, Next.js, Bun & SvelteKit.
https://arcjet.com
Apache License 2.0
182 stars 3 forks source link

fix(sveltekit): Load environment variables from process.env #989

Closed blaine-arcjet closed 1 month ago

blaine-arcjet commented 1 month ago

I can't find the actual part of the SvelteKit code that causes the import of "$env/dynamic/private" inside a node_module to fail, but I fixed our example so the problem surfaced.

I also discovered https://github.com/sveltejs/kit/issues/12028 which states that a warning should be added that third-party libraries should not use this import. And https://github.com/nextauthjs/next-auth/issues/9809 + https://github.com/nextauthjs/next-auth/pull/10117 which highlight problems when it is used.

Perhaps we'll need to explore something like https://github.com/nextauthjs/next-auth/discussions/6247 but it seems that process.env is populated in SvelteKit so we can use it for now.

Fixes #982

trunk-io[bot] commented 1 month ago

😎 Merged successfully - details.

socket-security[bot] commented 1 month ago

Removed dependencies detected. Learn more about Socket for GitHub ↗︎

🚮 Removed packages: npm/@sveltejs/adapter-node@5.1.0

View full report↗︎

blaine-arcjet commented 1 month ago

Also tested with bun run dev and it works since Bun supports process.env