Replies: 2 comments
-
|
There's a whole section on action variables here: https://docs.github.com/en/actions/learn-github-actions/variables |
Beta Was this translation helpful? Give feedback.
-
|
We ran into this exact issue deploying a Vite + React app that uses a Mapbox GL JS access token ( Here's what worked for us: 1. Hardcode a sensible default in source codeIn our app component we fall back to a baked-in default so it works out of the box locally and in CI without any extra setup: const DEFAULT_MAPBOX_TOKEN = 'pk.eyJ1Ijoic3...';
const MAPBOX_TOKEN =
(import.meta.env.VITE_MAPBOX_TOKEN as string | undefined) ||
DEFAULT_MAPBOX_TOKEN;2. Create a
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a React front-end project. For visiting back-end server, I have an API key. When developing, I set an environment variable named REACT_APP_API_KEY, and refer it in my javascript code as
process.env.REACT_APP_API_KEY. It works fine locally (when I runnpm start).But now I would like to deploy it on GitHub Pages. I have added the key as a secret in my GitHub repository (just like access token). But how can I set the enviroment variable?
Beta Was this translation helpful? Give feedback.
All reactions