Overview
CV Staff uses environment variables to store sensitive configuration data like API keys. These variables are stored in a.env file in the root of your project and should never be committed to version control.
Setup
Step 1: Create Environment File
CV Staff includes a.env.example file as a template. Copy it to create your own .env file:
Step 2: Configure Variables
Open the.env file and add your configuration values.
Available Variables
Groq API Key
Used for the AI chatbot functionality.- Visit Groq Console
- Create an account or sign in
- Generate a new API key
- Copy the key and paste it in your
.envfile
The
PUBLIC_ prefix makes this variable available to client-side code in Astro. Be aware that public variables can be seen by users in the browser.Using Environment Variables
In Astro Components
Access environment variables usingimport.meta.env:
In TypeScript/JavaScript Files
Environment Variable Naming
Astro supports two types of environment variables:Public Variables
Prefix:PUBLIC_
- Exposed to the client-side JavaScript
- Visible in the browser
- Use for non-sensitive configuration that needs to be accessed from the browser
Private Variables
No prefix required- Only available on the server-side
- Never exposed to the browser
- Use for sensitive data like database passwords
Validation
It’s good practice to validate that required environment variables are set:src/utils/env.ts
Environment-Specific Configuration
You can create different environment files for different environments:Example Configuration
Here’s a complete example of what your.env file might look like:
.env
Security Best Practices
Never Commit Secrets
Always add
.env to your .gitignore file to prevent accidental commits.Use .env.example
Keep
.env.example updated with all required variables (without actual values).Rotate Keys Regularly
Change API keys periodically and immediately if they are exposed.
Limit Scope
Use API keys with minimal required permissions.
Troubleshooting
Variables Not Loading
Issue: Environment variables are undefined Solutions:- Ensure the
.envfile is in the project root - Restart the development server after changing
.env - Check for typos in variable names
- Verify the
PUBLIC_prefix for client-side variables
API Key Not Working
Issue: Groq API returns authentication errors Solutions:- Verify the API key is correct and active in the Groq Console
- Check for extra spaces or newlines in the
.envfile - Ensure you’re using the correct key (test vs. production)
- Verify your Groq account has credits/quota available
Adding New Variables
When adding new environment variables:-
Update
.env.examplewith a placeholder: -
Add to your
.envwith the actual value: - Document it in your README or documentation
-
Add TypeScript types (optional but recommended):
src/env.d.ts
Production Deployment
When deploying to production:-
Never deploy the
.envfile - it should only exist locally -
Use your hosting platform’s environment variable settings:
- Vercel: Project Settings → Environment Variables
- Netlify: Site Settings → Build & Deploy → Environment
- Other platforms: Check their documentation
-
Set the same variables you have in
.envthrough the platform’s UI
Next Steps
Profile Data
Customize your professional information and CV content
Styling
Customize colors, fonts, and visual appearance