#Supabase Edge Functions with Dotenv Vault

7 messages · Page 1 of 1 (latest)

warped echo
#

I just cannot get this to work. Not even locally.

I'm using Supabase so the whole environment locally runs in Docker.

import { configSync } from "https://deno.land/std@0.167.0/dotenv/mod.ts";
import "https://deno.land/std@0.167.0/dotenv/load.ts";





console.log(configSync())
console.log(Deno.env.get("ENVIRONMENT"))
console.log("Hello from Functions!")```

This is the beginning of the code and below is the output:

```Serving supabase/functions/hello-world
Watcher Process started.
{
  JWT_SECRET: "secret",
  DENO_ORIGIN: "http://host.docker.internal:8082",
  VERIFY_JWT: "true"
}
undefined
Hello from Functions!```

Not really sure where to start my troubleshooting.
#

Also, a main part of why I cannot get this to work in Supabase itself is that I cannot provide Supabase's Edge Functions with the --allow-read and --allow-env options

warped echo
#

Made the file a little bit more minimalistic:

import "https://deno.land/std@0.167.0/dotenv/load.ts";

console.log(await config())
console.log(Deno.env.get("ENVIRONMENT"));```

However, still it's the same output:

```Serving supabase/functions/hello-world
Watcher Process started.
{
  JWT_SECRET: "secret",
  DENO_ORIGIN: "http://host.docker.internal:8082",
  VERIFY_JWT: "true"
}
undefined```

Also attached is the file tree, just  trying to include as much as possible.
warped echo
#

I think Dotenv Vault is simply not supported.

[dotenv-vault-core@0.6.1][INFO] Loading env from encrypted .env.vault
error: Uncaught Error: Not implemented: crypto.Decipheriv
  throw new Error(message);
        ^
    at notImplemented (https://deno.land/std@0.165.0/node/_utils.ts:23:9)
    at new Decipheriv (https://deno.land/std@0.165.0/node/internal/crypto/cipher.ts:196:5)
    at Object.createDecipheriv (https://deno.land/std@0.165.0/node/crypto.ts:214:10)
    at L (https://esm.sh/v99/dotenv-vault-core@0.6.1/deno/dotenv-vault-core.js:2:2579)
    at M (https://esm.sh/v99/dotenv-vault-core@0.6.1/deno/dotenv-vault-core.js:2:3637)
    at U (https://esm.sh/v99/dotenv-vault-core@0.6.1/deno/dotenv-vault-core.js:2:3773)
    at B (https://esm.sh/v99/dotenv-vault-core@0.6.1/deno/dotenv-vault-core.js:2:4366)
    at file:///home/deno/functions/hello-world/index.ts:10:13```

Had to really specify where to find the vault: 
```javascript
import { config } from 'https://esm.sh/dotenv-vault-core@0.6.1'

console.log(config({path: '/home/deno/functions/_shared/.env'}))
arctic gazelle
# warped echo I think Dotenv Vault is simply not supported. ```powershell [dotenv-vault-core@...

So it's working for you now? It might not be interesting at all to have your Edge Functions in Supabase, as they are "only a wrapper around Deno Deploy", Supabase staff own words. I use Deno Deploy for my functions and only use Supabase for the other services like the DB and Storage, so what Deno Deploy don't have. Plus, Supabase have less invokations of functions, both in the free tier and the paid tier while being more expensive.

Deno Pricing:

  • Free: 100K request a day, so 2.8 to 3.1M depending if the month have 28 or 31 days
  • $10: 5M request a month, that's ~164K request a day

Supabase Pricing:

  • Free: 500K request a month, that's ~16K a day
  • $25: 2M request a month, that's ~65K request a day
warped echo
#

@arctic gazelle No, it's not working. And indeed if I would reach those limits I'll surely move over to Deno natively. Right now it's just qol

arctic gazelle
#

Well speking of Quality Of Life... setting my env vars on the Deno Deploy Dashboard just works, I use: import "https://deno.land/std@0.167.0/dotenv/load.ts"; like your first code snippet