Skip to content

Environment variables

Backend (backend/.env)

Application

VariableExampleDescription
APP_NAMEExchangeProApplication name in emails
APP_VERSION1.0.0Product version (Admin → Extra → Application info)
APP_TIMEZONEUTCPHP timezone for displayed dates/times (list)
APP_ENVproductionlocal for dev
APP_KEY(generated)php artisan key:generate - required; missing key causes 500 on SPA requests
APP_DEBUGfalseMust be false in production
APP_URLhttps://api.yourdomain.comPublic URL of Laravel (public/)
FRONTEND_URLhttps://yourdomain.comNuxt site URL (password reset links, default CORS origin, Sanctum stateful domain)
CORS_ALLOWED_ORIGINS(optional)Comma-separated frontend origins with scheme - CORS

Database

VariableDescription
DB_CONNECTIONmysql, mariadb, or sqlite
DB_HOSTDatabase host
DB_PORT3306 for MySQL
DB_DATABASEDatabase name
DB_USERNAMEDatabase user
DB_PASSWORDDatabase password

Session & Sanctum

VariableLocal devProduction (subdomains)Description
SESSION_DRIVERdatabasedatabaseRequires sessions table from migrations
SESSION_DOMAINnull.yourdomain.comRequired when API and frontend use different subdomains
SESSION_SECURE_COOKIE(empty)trueSend cookies only over HTTPS
SESSION_SAME_SITElaxlaxKeep lax for same root domain (e.g. api. + apex)

Sanctum stateful domains are derived from FRONTEND_URL in config/sanctum.php - see CORS & Sanctum.

Queue & cache

VariableDefaultDescription
QUEUE_CONNECTIONdatabaseUse redis for higher throughput
CACHE_STOREdatabaseApplication cache

Mail

VariableDescription
MAIL_MAILERsmtp, log, etc.
MAIL_HOSTSMTP host
MAIL_PORT587 (TLS) common
MAIL_USERNAMESMTP user
MAIL_PASSWORDSMTP password
MAIL_FROM_ADDRESSSender email
MAIL_FROM_NAMESender name

See Mail.

OAuth (optional overrides)

Configured primarily in admin UI; optional env fallbacks in config/services.php:

VariableProvider
GOOGLE_CLIENT_IDGoogle
GOOGLE_CLIENT_SECRETGoogle
FACEBOOK_CLIENT_IDFacebook
FACEBOOK_CLIENT_SECRETFacebook

Admin settings override runtime via SocialAuthController.


Frontend (frontend/.env)

VariableExampleDescription
FRONTEND_URLhttps://yourdomain.comCanonical frontend origin
API_URLhttps://api.yourdomain.comLaravel API origin (no /api suffix)

These map to runtimeConfig.public in nuxt.config.ts:

ts
runtimeConfig: {
  public: {
    baseUrl: FRONTEND_URL,
    apiUrl: API_URL,
    sanctum: { baseUrl: API_URL },
  },
},

Rebuild the frontend after changing API_URL or FRONTEND_URL (npm run build).


Cross-app checklist

BackendFrontendMust match
APP_URLAPI_URLSame origin
FRONTEND_URLFRONTEND_URLSame public site URL
CORS_ALLOWED_ORIGINS (or FRONTEND_URL)FRONTEND_URLFrontend origin allowed

When using separate subdomains, also set on the backend:

ini
SESSION_DOMAIN=.yourdomain.com
SESSION_SECURE_COOKIE=true
SESSION_SAME_SITE=lax

Example production pair (subdomains)

Real-world layout (replace xorinlab.com with your domain):

Backend .env:

ini
APP_ENV=production
APP_DEBUG=false
APP_KEY=base64:...
APP_URL=https://api-exchangepro.xorinlab.com
FRONTEND_URL=https://exchangepro.xorinlab.com

SESSION_DRIVER=database
SESSION_DOMAIN=.xorinlab.com
SESSION_SECURE_COOKIE=true
SESSION_SAME_SITE=lax

Frontend .env:

ini
FRONTEND_URL=https://exchangepro.xorinlab.com
API_URL=https://api-exchangepro.xorinlab.com

Optional - allow both apex and www:

ini
CORS_ALLOWED_ORIGINS=https://exchangepro.xorinlab.com,https://www.exchangepro.xorinlab.com

After editing backend .env:

bash
php artisan config:clear
php artisan config:cache

Example local development

Backend .env:

ini
APP_URL=http://localhost:8000
FRONTEND_URL=http://localhost:4000
SESSION_DOMAIN=null
SESSION_SECURE_COOKIE=
SESSION_SAME_SITE=lax

Frontend .env:

ini
FRONTEND_URL=http://localhost:4000
API_URL=http://localhost:8000

Need help? support@xorinlab.com · Website: xorinlab.com