IP Address Tracker made with tailwind, react/typescript, vite
Design comparison
Solution retrospective
I could not setup an environment variable using Vite and Netlify, I used "import.meta.env.VITE_KEY" in my local file and .env (it works great, locally), but at Netlify it was showing undefined and failing to fetch the leaflet map.
Community feedback
- @mike1233Posted almost 2 years ago
Hello,
To answer your queston about env variables. you need to set the variable in the command line before you execute the vite build command.
vite docs:
In addition, environment variables that already exist when Vite is executed have the highest priority and will not be overwritten by .env files. For example, when running VITE_SOME_KEY=123 vite build.
in my case i had to do the following with github actions
- name: Install 🔧 run: npm ci - name: Build 🏗️ run: npm run build env: VITE_GEOLOCATION_API_KEY: ${{secrets.apikey}}
Now i dont know exactly how your deployprocess works with netlify but i hope this points you into the right direction!
1
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord