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
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)
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

VariableDescription
SESSION_DRIVERDefault database — requires sessions table
SESSION_DOMAINSet for cross-subdomain cookies if needed (e.g. .yourdomain.com)
SANCTUM_STATEFUL_DOMAINSComma-separated frontend hosts — details

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 },
  },
},

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
SANCTUM_STATEFUL_DOMAINShost of FRONTEND_URLCookie auth works

Example production pair

Backend .env:

ini
APP_URL=https://api.exchangepro.com
FRONTEND_URL=https://exchangepro.com

Frontend .env:

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

Backend .env (CORS uses FRONTEND_URL by default; add www if needed):

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

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