Overview
Cat Web requires several environment variables to connect to your Auth0 tenant and backend API. This guide walks you through setting up your configuration.Required Environment Variables
Cat Web uses Vite’s environment variable system, which requires all variables to be prefixed withVITE_ to be exposed to the client.
Environment Variables
Create a.env file in the root of your project with the following variables:
Your Auth0 tenant domain (e.g.,
your-tenant.auth0.com or your-tenant.us.auth0.com)The Client ID from your Auth0 Application settings
The API identifier/audience for your Auth0 API
The base URL for your backend API (e.g.,
http://localhost:8080 for local development or your production API URL)Auth0 Setup
To obtain the required Auth0 credentials, follow these steps:Create an Auth0 Account
If you don’t have an Auth0 account, sign up at auth0.com.
Create a Single Page Application
In your Auth0 Dashboard:
- Navigate to Applications > Applications
- Click Create Application
- Enter a name (e.g., “Cat Web”)
- Select Single Page Web Applications
- Click Create
Configure Application Settings
In your application settings, configure the following:Allowed Callback URLsAllowed Logout URLsAllowed Web OriginsAllowed Origins (CORS)Click Save Changes at the bottom of the page.
Get Your Credentials
From the application settings page, copy:
- Domain →
VITE_AUTH0_DOMAIN - Client ID →
VITE_AUTH0_CLIENT_ID
Environment File Setup
After creating or modifying the
.env file, restart your development server for changes to take effect.Configuration in Code
Auth0 Provider Setup
The Auth0 provider is configured insrc/main.tsx:
API Service Configuration
The API service uses theVITE_API_BASE_URL environment variable in src/services/api-service.ts:
Configuration Validation
To verify your configuration is correct:Test authentication
Click the login button. You should be redirected to Auth0’s login page.
If you see the Auth0 login page, your configuration is correct.
Troubleshooting
Error: domain is required
Error: domain is required
This error indicates that
VITE_AUTH0_DOMAIN is not set or is empty.Solution:- Verify your
.envfile containsVITE_AUTH0_DOMAIN - Restart the development server
- Clear your browser cache
Error: clientId is required
Error: clientId is required
This error indicates that
VITE_AUTH0_CLIENT_ID is not set or is empty.Solution:- Verify your
.envfile containsVITE_AUTH0_CLIENT_ID - Ensure you copied the correct Client ID from Auth0
- Restart the development server
Redirect URI mismatch error
Redirect URI mismatch error
This error occurs when the callback URL is not configured in Auth0.Solution:
- Go to your Auth0 Application settings
- Add your application URL to Allowed Callback URLs
- Add your application URL to Allowed Web Origins
- Save changes and try again
API calls returning 401 Unauthorized
API calls returning 401 Unauthorized
Environment variables showing as undefined
Environment variables showing as undefined
Vite only exposes variables prefixed with
VITE_.Solution:- Ensure all variables start with
VITE_ - Restart the development server after modifying
.env - Clear Vite’s cache:
rm -rf node_modules/.vite
Production Configuration
For production deployments, set environment variables through your hosting platform:Next Steps
With your configuration complete, you’re ready to start using Cat Web!User Guide
Learn how to use Cat Web’s features
API Reference
Explore the API service methods
