Overview
The Nadie Sabe Nada podcast application uses environment variables to configure external API integrations. All environment variables follow the React convention and are prefixed withREACT_APP_.
Environment variables in Create React App must be prefixed with
REACT_APP_ to be accessible in the application.Required Variables
The application requires the following environment variables for full functionality:YouTube Data API v3 key used to search for podcast videos on YouTube.Usage Location:
src/components/PodcastDetail/PodcastDetail.jsx:43src/components/LastPodcast/LastPodcast.jsx:41
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the YouTube Data API v3
- Create credentials (API Key)
- Copy the generated API key
The YouTube channel ID for the Nadie Sabe Nada podcast channel. This is used to filter YouTube search results to only show videos from the official channel.Usage Location:
src/components/PodcastDetail/PodcastDetail.jsx:44src/components/LastPodcast/LastPodcast.jsx:42
- Go to the Nadie Sabe Nada YouTube channel
- The channel ID is in the URL or can be found in the channel’s About page
- It typically starts with
UCfollowed by alphanumeric characters
Setting Environment Variables
Development
Create a.env file in the root directory of your project:
Production
For production deployments, set environment variables through your hosting platform:- Vercel
- Netlify
- GitHub Pages
- Go to your project settings
- Navigate to “Environment Variables”
- Add
REACT_APP_YT_API_KEYandREACT_APP_CHANNEL_ID - Redeploy your application
How Environment Variables are Used
The application uses these environment variables to fetch YouTube videos for each podcast episode:PodcastDetail.jsx
Default Values
There are no default values for environment variables. If these variables are not set, the YouTube video integration will not function, but the audio player will continue to work.
Troubleshooting
Variables Not Loading
- Ensure the
.envfile is in the root directory (same level aspackage.json) - Restart the development server after adding/changing environment variables
- Verify the
REACT_APP_prefix is included - Check for typos in variable names
YouTube API Errors
- 403 Forbidden: Your API key may be invalid or the YouTube Data API is not enabled
- Quota Exceeded: You’ve reached your daily API quota limit
- Invalid Channel ID: Verify the channel ID is correct
Security Best Practices
API Key Restrictions
Restrict your YouTube API key in Google Cloud Console:- Application restrictions: Set to “HTTP referrers”
- Add your domain:
https://yourdomain.com/* - API restrictions: Limit to YouTube Data API v3 only
Complete Example
Here’s a complete example.env file with explanations:
.env
