[Resolved] Accessing .env vars and syntax error

Hi! I have a little Node + Express + SQLite app, with a couple of variables in my .env like this (not the real values, but similar):

API_KEY=SomeKeyWithSpecialCharsLike)And(
ADMIN_PWD=SomeAdminPassword

1) Accessing

I’m a bit rusty on my Node and quite new to Glitch, but I thought these should be available in the server-side code (server.js) without having to do anything further, with process.env.API_KEY and process.env.ADMIN_PWD? But when I log them to check (printed as soon as the app reloads), they’re undefined.

It works fine when I use the dotenv package and call dotenv.load({silent: true}); first though. Is that - or something similar - required?

2) Syntax error

I’m also getting an error every time the app reloads:

.env: line 5: syntax error near unexpected token `)'
.env: line 5: `API_KEY=SomeKeyWithSpecialCharsLike)And('

This happens whether or not I am using dotenv.

Please might someone be able to point out where I’m going wrong? :slight_smile: (It’s this project here: https://glitch.com/edit/#!/samsung-internet-dashboard). Thanks!

Sorry! Nothing to do with Glitch - I just needed to escape the special characters with backslash, then it works fine! I was too hasty to post here - apologies - please delete this post if that’s best :slight_smile:

Glad you got it sorted!