Overview
The PC Fix monorepo has two main packages that require separate environment configuration:- packages/api: Backend API with database, authentication, and integrations
- packages/web: Frontend application with Astro and React
Never commit
.env files to version control. Add them to .gitignore and use .env.example as a template.Backend Environment Variables
Createpackages/api/.env with the following configuration:
Database Configuration
.env
Database URL Format
Database URL Format
The
DATABASE_URL follows this format:- USER: Database username (default:
admin) - PASSWORD: Database password (default:
password123) - HOST: Database host (
localhostfor local,postgresfor Docker) - PORT: Database port (default:
5432) - DATABASE: Database name (default:
pcfix_db)
Authentication & Security
.env
Configure Google OAuth
- Go to Google Cloud Console
- Create a new project or select existing
- Enable Google+ API
- Create OAuth 2.0 credentials
- Add authorized redirect URIs
- Copy the Client ID to your
.env
External Services
.env
Server Configuration
.env
Frontend Environment Variables
Createpackages/web/.env with the following configuration:
API Connection
.env
In Docker environments, use
SSR_API_URL="http://api:3002/api" to leverage Docker’s internal networking.Google OAuth (Frontend)
.env
Sentry (Frontend)
.env
External Services Setup
Cloudinary Setup
Cloudinary Setup
- Sign up at cloudinary.com
- Navigate to Dashboard
- Copy Cloud Name, API Key, and API Secret
- Add credentials to
packages/api/.env
- Product image uploads
- Payment receipt uploads
- CDN delivery
MercadoPago Setup
MercadoPago Setup
- Create account at mercadopago.com
- Go to Your integrations
- Create a new application
- Copy the Access Token (use Test credentials for development)
- Configure webhook URL:
https://your-api-url.com/api/sales/mp-webhook
- Approved:
4509 9535 6623 3704(any future date, any CVV) - Rejected:
4017 1410 1414 1234
Resend Setup
Resend Setup
- Sign up at resend.com
- Verify your domain or use their test domain
- Generate an API key
- Add to
packages/api/.env
- Order confirmations
- Payment receipts
- Password reset links
- Abandoned cart reminders
- Stock alerts
Sentry Setup
Sentry Setup
- Sign up at sentry.io
- Create two projects:
- PC Fix API (Node.js)
- PC Fix Web (Astro/Browser)
- Copy both DSN values
- Add to respective
.envfiles
- Backend: Server errors, unhandled exceptions
- Frontend: JavaScript errors, failed requests
Environment Templates
Create.env.example files in both packages for team reference:
- API .env.example
- Web .env.example
packages/api/.env.example
Validation
Verify your configuration is correct:Troubleshooting
Database connection failed
Database connection failed
- Verify PostgreSQL is running:
pg_isready - Check DATABASE_URL format and credentials
- Ensure database
pcfix_dbexists - For Docker: use host
postgresinstead oflocalhost
JWT errors
JWT errors
- Ensure JWT_SECRET is set and not empty
- Regenerate secrets if you suspect compromise
- Check token expiration times are valid
CORS errors
CORS errors
- Verify FRONTEND_URL matches your frontend’s actual URL
- Include protocol (http:// or https://)
- For Docker, add both
localhostand container URLs to whitelist
External service errors
External service errors
- Test API keys in service dashboards first
- Check for typos in credentials
- Verify services are not rate-limited
- Check service status pages for outages
Next Steps
Docker Deployment
Deploy PC Fix with Docker Compose
Database Migrations
Manage database schema changes
Testing
Run unit and E2E tests
Integrations
Configure payment providers