Skip to content

Problem with .env environment variables (using Deno) #3501

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

Open
lbois opened this issue Apr 29, 2025 · 0 comments
Open

Problem with .env environment variables (using Deno) #3501

lbois opened this issue Apr 29, 2025 · 0 comments

Comments

@lbois
Copy link

lbois commented Apr 29, 2025

Describe the bug
I have a function that sends an email, using mailjet. API KEY and API SECRET are stored in a .env file located in supabase/functions/send-email folder.

I've installed supabase locally (npm install supabase) and tested as is in a simple TS file:

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

console.log("MAILJET_API_KEY:", Deno.env.get("MAILJET_API_KEY"));
console.log("MAILJET_API_SECRET:", Deno.env.get("MAILJET_API_SECRET"));

The values are well displayed when executed.

My send-email/index.ts + .env are deployed to supabase.com as is
supabase functions deploy send-email --project-ref <project_id>

in index.ts I have a console.log as previously on the 2 environment variables values

When I execute the function remotely by a curl command I got an error mailjet but the log of the Edge fiunction send-email on supabase.com shows me that the 2 environment variables are 'undefined'.

url -X POST 'https://<project_id>.supabase.co/functions/v1/send-email'
-H "Content-Type: application/json"
-H "Authorization: Bearer "
-d '{
"to": ["a_user@an_email.com"],
"subject": "Test depuis Supabase Edge Function",
"message": "Ceci est un test via Supabase",
"collectionName": "Ma Collection",
"fileCount": 1
}'

Thanks for your help

Laurent
System information
Rerun the failing command with --create-ticket flag.

  • Ticket ID: [e.g. ab1ac733e31e4f928a4d7c8402543712]
  • Version of OS: MacOS Sequoia 15.4.1
  • Version of CLI: supbase v2.22.6 (locally)

Additional context
If applicable, add any other context about the problem here.

  • Browser Chrome
  • Version of Node.js [v22.15]
Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant