How to access secrets in a very basic NextJS app?

I setup a super simple NextJS with a simple action that returns process.env.SECRET_WORD

with my app having a secret SECRET_WORD

but then when I deploy, I see nothing.

strangely enough, it works in a simple nodejs just not nextjs

export async function test() {
return process.env.NODE_ENV + " " + process.env.SECRET_WORD;
}

renders to

“production undefined”

so it’s definitely getting some environment variables, just not the ones in my secrets

choose-your-own/my-test on  main [?] via  v20.12.2 took 1m37s
❯ fly secrets list
NAME DIGEST CREATED AT
SECRET_WORD 8cfa2bd38c19599e 9m28s ago

oops, totally forgot the “use server” at the top

“use server”;

export async function test() {
return process.env.NODE_ENV + " " + process.env.SECRET_WORD;
}

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.