Next.js Discord

Discord Forum

environment variables refuse to update

Answered
Koolie posted this in #help-forum
Open in Discord
KoolieOP
I was using a .env file to load in my environment variables. one of which was a Cloudflare turnstile public key.

My current .env/.env.local file looks like this
NEXT_PUBLIC_SUPABASE_URL='1234'
NEXT_PUBLIC_SUPABASE_ANON_KEY='1234'

# REAL KEY
NEXT_PUBLIC_TURNSTILE_SITE_KEY='0x1234'

# Always passes
# NEXT_PUBLIC_TURNSTILE_SITE_KEY='1x00000000000000000000AA'

but if i run something like
console.log(process.env.NEXT_PUBLIC_TURNSTILE_SITE_KEY);

it prints out
"'1x00000000000000000000AA' # Always passes"
which is what the env value used to be.


* I have restarted the app
* deleted my .next folder
* deleted and resinstalled my node_modules
* restarted my computer
* searched through the filesystem to make sure i had not hard coded it anywhere
* and even deleted my .env file

The problem is both server and clientside
This only effect some ENV variables, specifically ones that I have had for a while

I dont now what to do to fix it
Answered by Koolie
yes, and i just found a solution. I deleted the entire project folder and re cloned my github repo from the latest version. this cleaned god knows what and it seems to have fixed it
View full answer

8 Replies

Chum salmon
Don't put quote around the value
Try that first and let's see
KoolieOP
forgot to update this, tried that but did not help
Chum salmon
Let me make it clear. Your current issue is that the values from env variables are not updated?
It uses the old values?
KoolieOP
yes
Chum salmon
In what context? During the dev in your localhost?
KoolieOP
yes, and i just found a solution. I deleted the entire project folder and re cloned my github repo from the latest version. this cleaned god knows what and it seems to have fixed it
Answer
Chum salmon
Awesome. glad it works out