How to access .env variables using dotenv

I have followed the instructions in here:

  1. Dotenv is installed
  2. There’s a route extension called dotenv.js that has the line require('dotenv').config()
  3. Created a .env file in the root folder of the project with two key value pairs

I can’t seem to get the value’s out. I tried in two ways:

  1. Setting a value and opening the server action in the browser

    There’s nothing there…

  2. On a page using EJS image →it shows empty

Am I doing it wrong?
@patrick @JonL

You need to insert it as server binding in the EJS page.

<%=_('$_ENV.APP_ID',locals)%>

Thanks @patrick, still doesn’t seem to work.
Copied your code:

Shows nothing on page:

.env contents and place in folder:


(I’m using Docker if it matters)

PS
I also tried to get it to print using a route extension:

Goal is to be able to use them in server actions though.

The dotenv module is already installed and used by server connect, it get only used in development used, when you want to use it in production then edit the file lib/server.js.

Sorry, I don’t understand. I’m in development right now (local development docker server). But I can’t seem to get the value out of the .env file