Environment variables
All configuration is done through environment variables prefixed withVITE_. Create a .env file in the root directory of your project.
Required variables
These variables must be set for the application to function:VITE_SUPABASE_URL
The URL of your Supabase project.You can find this value in your Supabase project dashboard under Settings > API > Project URL.
VITE_SUPABASE_ANON_KEY
The anonymous (public) API key for your Supabase project.Optional variables
These variables have default values but can be customized:VITE_MAX_FILE_SIZE_MB
Maximum file size in megabytes for document uploads (lab results, medical images, etc.).10 (10 MB)
VITE_BUCKET_NAME
The name of the Supabase Storage bucket for file uploads.00000000-default-bucket
Advanced optional variables
VITE_APP_VERSION
Application version string sent with API requests.dev
This value is automatically sent in the API headers:
VITE_SUPABASE_DETECT_SESSION_IN_URL
Enable OAuth session detection from URL parameters.false
This is disabled by default for better performance. Only enable if you’re using OAuth providers (Google, GitHub, etc.).
Complete .env file example
Here’s a complete example with all variables:Supabase setup
DoctorSoft+ requires a properly configured Supabase project. Follow these steps to set up your backend.Create a Supabase project
- Go to supabase.com and sign in
- Click “New Project”
- Choose a name and strong database password
- Select a region close to your users
- Wait for the project to finish provisioning
Get your API credentials
Navigate to Settings > API in your Supabase dashboard:
- Copy the Project URL → Use for
VITE_SUPABASE_URL - Copy the anon public key → Use for
VITE_SUPABASE_ANON_KEY
Set up authentication
DoctorSoft+ uses Supabase Auth for user management:
- Go to Authentication > Settings in Supabase
- Configure your email templates (optional)
- Set up your site URL:
http://localhost:5173for development - Add redirect URLs if needed
Configure storage bucket
For file uploads (medical documents, images):
- Go to Storage in your Supabase dashboard
- Create a new bucket or use the default bucket
- Set up Row Level Security (RLS) policies:
- Allow authenticated users to upload files
- Allow users to read their own files
- Restrict deletion to file owners or admins
.env with the bucket name:Supabase client configuration
DoctorSoft+ includes advanced Supabase client configuration for optimal performance and reliability.Connection timeout
The client uses a 15-second timeout for API requests:Authentication options
The client is configured with these auth settings:PKCE (Proof Key for Code Exchange) provides enhanced security for the authentication flow.
Realtime configuration
Realtime subscriptions are configured with rate limiting:Custom headers
All API requests include the application version:Build-time validation
DoctorSoft+ validates configuration at build time to catch errors early:Runtime validation
The Supabase client also validates configuration at runtime:Deployment configuration
For production deployments, environment variables must be configured in your hosting platform:Netlify
- Go to Site Settings > Build & Deploy > Environment
- Add all required environment variables
- Configure build settings:
- Build command:
npm run build - Publish directory:
dist
- Build command:
Vercel
- Go to Project Settings > Environment Variables
- Add all required variables for Production, Preview, and Development
- Configure build settings:
- Framework Preset: Vite
- Build Command:
npm run build - Output Directory:
dist
Other platforms
For any platform:- Set Node.js version to 18+
- Add all environment variables
- Set build command to
npm run build - Set output directory to
dist
Security best practices
Never commit secrets
Add.env to your .gitignore:
Use different credentials per environment
Use separate Supabase projects for development, staging, and production:dev-project.supabase.cofor local developmentstaging-project.supabase.cofor testingprod-project.supabase.cofor production
Rotate keys regularly
Periodically rotate your Supabase API keys, especially if they may have been compromised.Troubleshooting
Environment variables not loading
If environment variables aren’t being loaded:- Ensure your
.envfile is in the root directory - Restart the development server:
npm run dev - Check that variables are prefixed with
VITE_ - Verify no syntax errors in the
.envfile
Supabase connection errors
Detailed error information is logged to the console:Next steps
- Follow the quickstart guide to start using DoctorSoft+
- Learn about deployment for production
- Review the API documentation for advanced usage