Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Hazielgmz/astro-Portfolio/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Astro Portfolio requires environment variables to connect to your Supabase backend database. These credentials should be stored in a.env file that is never committed to version control.
Required Variables
SUPABASE_URL
Your Supabase project URL. Format:https://your-project-id.supabase.co
Where to find it:
- Open your Supabase Dashboard
- Select your project
- Go to Project Settings → API
- Copy the Project URL
SUPABASE_KEY
Your Supabase anonymous/public API key. Format: A long alphanumeric string (JWT token) Where to find it:- Open your Supabase Dashboard
- Select your project
- Go to Project Settings → API
- Copy the anon/public key (NOT the service role key)
Setup Instructions
Step 1: Create .env File
In the root of your project (same directory aspackage.json), create a .env file:
Step 2: Add Your Credentials
Add the following to your.env file:
Step 3: Verify .gitignore
Ensure.env is listed in your .gitignore file to prevent accidentally committing secrets:
Usage in Code
The environment variables are accessed using Astro’simport.meta.env API:
In Astro Components
Environment-Specific Configuration
Development
Use.env for local development:
Production
For production deployments, set environment variables in your hosting platform:Vercel
- Go to your project on Vercel Dashboard
- Navigate to Settings → Environment Variables
- Add:
SUPABASE_URL→ your production URLSUPABASE_KEY→ your production key
- Select Production environment
- Click Save
Netlify
- Go to Site Settings → Build & Deploy → Environment
- Click Edit Variables
- Add your variables
- Save and redeploy
Other Platforms
Most platforms support environment variables via:- Dashboard UI
- CLI commands
- Configuration files
Security Best Practices
✅ Do
- Use the anon/public key for client-side code
- Enable Row Level Security (RLS) on all Supabase tables
- Create separate Supabase projects for development and production
- Rotate keys if accidentally exposed
- Use different keys per environment
❌ Don’t
- Never use the service role key in client-side code
- Don’t commit
.envfiles to Git - Don’t share keys in public forums or screenshots
- Don’t hardcode credentials directly in source files
Troubleshooting
Error: “supabaseUrl is required”
Cause: Environment variables not loaded. Solution:- Verify
.envfile exists in project root - Check variable names match exactly (case-sensitive)
- Restart the dev server:
npm run dev
Error: “Invalid API key”
Cause: Wrong key or key expired. Solution:- Re-copy the key from Supabase dashboard
- Ensure you’re using the anon key, not service role
- Check for extra spaces or line breaks
Error: “Failed to fetch”
Cause: Network issue or incorrect URL. Solution:- Verify
SUPABASE_URLis correct - Check internet connection
- Ensure Supabase project is active (not paused)
Template
Copy this template for your.env file:
Next Steps
- Set up your Supabase database
- Customize styling
- Learn about deployment
The portfolio is configured for Server-Side Rendering (SSR) with Vercel adapter. Environment variables are accessed at build time and runtime.