Reading environment variables from server (not .env file) when using @quasar/quasar-app-extension-dotenv



  • Hi,

    I’m using @quasar/quasar-app-extension-dotenv for loading environment variables during the development from .env file on my localhost.

    In the production I’m hosting the project on Netlify and when I set the environment variables in the Netlify dashboard it is undefined during the program run.

    My quasar.extensions.json looks like this:

    {
      "@quasar/dotenv": {
        "env_development": ".env",
        "env_production": ".env",
        "common_root_object": "none",
        "create_env_files": false,
        "add_env_to_gitignore": false       
      }
    }
    

    Any ideas how to load variables from server variables?

    Thanks



  • I did this on Azure by serving the Vue app as a Node/Express public folder, then create an endpoint on Express that returns the process.env object to the Vue application’s GET request. Worked like a charm.

    Create an express project. Add interface/ to the root and then build your Vue app there. Set Express to serve interface/dist and your builds will be served by Express.

    Deploy the express app to your web application.



  • @JiProchzaka The way I use Netlify, is that it pulls my Github repo over and builds it. You shouldn’t be keeping your .env in a repo because they usually contain sensistive data. But, that means Netlify will build your project without a .env, meaning no variables. 😞

    At least, this is my hypothesis for you.


Log in to reply