Environment Setup Guide#
This guide will help you set up the Kaneo development environment and troubleshoot common issues.
Quick Start#
-
Create a
.envfile in the root of the project with the required environment variables (see the documentation for the complete list). -
Start the development servers:
pnpm dev
This starts both the API (port 1337) and web app (port 5173). Both will automatically reload when you make changes.
Tip: The web app at http://localhost:5173 will automatically connect to the API at http://localhost:1337
Environment Variables#
Kaneo uses a single .env file in the root of the project for all environment variables. This file is shared by both the API and web services.
Required Variables#
For development, you'll need at minimum:
KANEO_CLIENT_URL- The URL of the web application (e.g.,http://localhost:5173)KANEO_API_URL- The URL of the API (e.g.,http://localhost:1337)AUTH_SECRET- Secret key for JWT token generation (must be at least 32 characters long; use a long, random value in production)DATABASE_URL- PostgreSQL connection stringPOSTGRES_DB- PostgreSQL database namePOSTGRES_USER- PostgreSQL usernamePOSTGRES_PASSWORD- PostgreSQL password
Development-Specific Variables#
For local development, the web app also supports:
VITE_API_URL- API URL for development (defaults tohttp://localhost:1337if not set)VITE_APP_URL- App URL for generating links (optional)
Optional Variables#
Kaneo supports many optional configuration options including:
- SSO providers (GitHub, Google, Discord, Custom OAuth/OIDC)
- SMTP configuration for email
- Access control settings
- CORS configuration
SMTP Configuration#
For sending emails (workspace invitations, magic links, etc.), configure these variables:
SMTP_HOST- SMTP server hostnameSMTP_PORT- SMTP server portSMTP_USER- SMTP usernameSMTP_PASSWORD- SMTP passwordSMTP_FROM- From email addressSMTP_SECURE- Use TLS (default:true, set tofalseto disable)SMTP_REQUIRE_TLS- Require TLS (default:false, set totrueto require)SMTP_IGNORE_TLS- Ignore TLS certificate errors (default:false, set totruefor self-signed certificates)
Note: If you're using an SMTP server with a self-signed or invalid TLS certificate, set
SMTP_IGNORE_TLS=trueto bypass certificate validation.
For a complete list of all environment variables, their descriptions, and configuration options, see the official documentation.
Common Issues & Troubleshooting#
CORS Errors#
Symptoms:
- "Failed to fetch" errors in browser console
- Network errors when making API requests
- "Access to fetch at '...' from origin '...' has been blocked by CORS policy"
Solutions:
-
Check URL Configuration:
- Ensure
KANEO_API_URLmatches your API server URL - Ensure
KANEO_CLIENT_URLmatches your web app URL - For development, you can also set
VITE_API_URLin your.envfile
- Ensure
-
Configure CORS Origins:
- Add your frontend URL to
CORS_ORIGINSin your.env:CORS_ORIGINS=http://localhost:5173,https://yourdomain.com - For development, you can leave
CORS_ORIGINSempty to allow all origins - Note:
CORS_ORIGINSshould matchKANEO_CLIENT_URLfor proper authentication
- Add your frontend URL to
-
Check Protocol Consistency:
- Ensure both frontend and API use the same protocol (http/https)
- Don't mix http and https in development
-
Verify Server Accessibility:
- Test if the API is accessible:
curl http://localhost:1337/config - Check if the server is running on the correct port
- Test if the API is accessible:
Database Connection Issues#
Symptoms:
- "Database connection failed" errors
- API server won't start
Solutions:
-
Check PostgreSQL:
- Ensure PostgreSQL is running
- Verify database exists and credentials are correct
- Test connection:
psql $DATABASE_URL
-
Update DATABASE_URL:
- Ensure the connection string format is correct
- Check username, password, host, port, and database name
Authentication Issues#
Symptoms:
- "Authentication failed" errors
- Users can't sign in
Solutions:
-
Check Authentication Configuration:
- Ensure
AUTH_SECRETis set in your.envfile - Use a strong secret in production
- Verify
KANEO_CLIENT_URLandKANEO_API_URLare correctly configured
- Ensure
-
Clear Browser Data:
- Clear cookies and local storage
- Try in incognito/private mode
Network Errors#
Symptoms:
- "Network error" messages
- API requests timeout
Solutions:
-
Check Server Status:
- Verify API server is running
- Check server logs for errors
-
Check Firewall/Proxy:
- Ensure ports are not blocked
- Check if proxy settings interfere
-
Verify URLs:
- Check that all URLs are accessible
- Test with curl or browser
Development vs Production#
Development#
- Use
http://localhostfor both frontend and API - Leave
CORS_ORIGINSempty to allow all origins (or set it to match your local URLs) - Use simple secrets for
AUTH_SECRET(not for production) - The web app will use
VITE_API_URLif set, otherwise defaults tohttp://localhost:1337
Production#
- Use HTTPS for both frontend and API
- Set specific
CORS_ORIGINSfor security (should matchKANEO_CLIENT_URL) - Use strong, unique secrets for
AUTH_SECRET - Configure proper database credentials
- Ensure
KANEO_CLIENT_URLandKANEO_API_URLare set to your production URLs
Getting Help#
If you're still experiencing issues:
- Check the browser console for detailed error messages
- Review the API server logs
- Verify all environment variables are set correctly
- Ensure all services (PostgreSQL, API, Frontend) are running
- Consult the official documentation for detailed guides and troubleshooting
For the most up-to-date information on environment variables and configuration, always refer to the official documentation.