I have a file in my Nuxt.js project that simply resides in the src directory. Therefore it is not in the convention of a Nuxt project. Therefore I understand that environment variables defined in the nuxt.config.js will not appear in the file placed in src.
However I'd still like to use environment variables in that mentioned file. This is how I try to access the environment variable:
const GAMESERVER_URL = process.env.GAMESERVER_URL || 'http://localhost:1001'
Unfortunately it always falls back to the default value http://localhost:1001. I have another file used as Nuxt.js plugin that is referencing the very same environment variable with the exact same statement (above). The plugin file works fine and is using the environment variable correctly.
What are my options to also introduce the environment variables to my standalone file in the src directory?