skip to Main Content

How do I get Amplify’s Environment Variable on a Vite React application? I’ve tried console logging to the import.meta.env, but only the process_env is showing. What do I need to do?

2

Answers


  1. Chosen as BEST ANSWER

    The reason why it wasn't showing was that we added the environment variable AFTER the build. In order for the environment variable to show, you have to declare it first before building.


  2. Please rename your environment variables so that they’d start with VITE_ prefix. According to the Vite documentation, any environment variable that does not start with VITE_ will not be exposed on the browser side to prevent accidental leaking of variables.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search