Overview
CEDIS Pedidos requires specific environment variables to connect to your Supabase backend. This guide walks you through configuring your local development environment and understanding the required variables.Required Environment Variables
The application requires two essential environment variables to connect to Supabase:| Variable | Description | Example |
|---|---|---|
VITE_SUPABASE_URL | Your Supabase project URL | https://xxxxx.supabase.co |
VITE_SUPABASE_ANON_KEY | Your Supabase anonymous/public key | eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... |
These variables use the
VITE_ prefix because the application is built with Vite. This prefix exposes the variables to the client-side code.Local Development Setup
Install dependencies
Install all required Node.js dependencies using npm:The application requires Node.js to be installed on your system. The key dependencies include:
- React 19 for the UI framework
- Vite 6 for build tooling and development server
- Supabase JS Client for backend connectivity
- Tailwind CSS for styling
Create environment file
Create a Add your Supabase credentials to the Replace the placeholder values with your actual Supabase credentials obtained from your Supabase project dashboard.
.env file in the root directory of the project:.env file:.env
Verify configuration
The Supabase client configuration validates that environment variables are set at runtime:If variables are missing, the application will throw an error on startup.
src/lib/supabase.ts
Start development server
Start the Vite development server:The development server will start on
http://localhost:5173 by default (or another port if 5173 is in use).The Vite configuration enables network access (
host: true), allowing you to access the development server from other devices on your local network.Development Configuration
Vite Configuration
The application uses a custom Vite configuration (vite.config.ts):
vite.config.ts
- Path alias:
@/maps to./src/for cleaner imports - Network access: Development server accessible on local network
- React plugin: Fast Refresh for instant HMR
- Tailwind CSS: Vite plugin for Tailwind v4
NPM Scripts
Available scripts frompackage.json:
Obtaining Supabase Credentials
To get your Supabase environment variables:Access project dashboard
Log in to your Supabase dashboard at https://app.supabase.com
Security Best Practices
Row Level Security
The application relies on Supabase Row Level Security (RLS) policies to protect data. Even though theanon key is exposed in the client-side code, RLS ensures:
- Users can only access data they’re authorized to see
- Sucursales (branches) can only view their own orders
- Admins have elevated permissions across all data
- Database operations are validated server-side
Troubleshooting
Missing Environment Variables
Error:Missing Supabase environment variables. Check .env file.
Solution: Ensure your .env file exists in the project root and contains both required variables.
Connection Errors
Error: Cannot connect to Supabase Solution:- Verify your
VITE_SUPABASE_URLis correct - Check that your Supabase project is active
- Ensure your API key hasn’t been revoked
Build Errors
Error: TypeScript compilation errors Solution:Next Steps
Once your local environment is configured:- Configure Supabase - Set up your database schema and RLS policies
- Deploy to Vercel - Deploy your application to production