Skip to content

๐Ÿ›ก๏ธ CORS & Security โ€‹

KitchenAsty includes several security measures out of the box.

๐ŸŒ CORS โ€‹

Cross-Origin Resource Sharing is configured via the CORS_ORIGINS environment variable:

dotenv
CORS_ORIGINS=http://localhost:5173,http://localhost:5174

The server parses this comma-separated list and allows requests from those origins with credentials: true.

In production, set this to your actual domain(s):

dotenv
CORS_ORIGINS=https://admin.yourrestaurant.com,https://order.yourrestaurant.com

๐Ÿช– Helmet โ€‹

Helmet sets various HTTP security headers:

  • ๐Ÿ”’ X-Content-Type-Options: nosniff
  • ๐Ÿ–ผ๏ธ X-Frame-Options: SAMEORIGIN
  • ๐Ÿ” Strict-Transport-Security (in production)
  • ๐Ÿ“œ Content Security Policy headers
  • And more

Helmet is enabled by default with standard settings.

๐Ÿšฆ Rate Limiting โ€‹

API endpoints are rate-limited to prevent abuse:

SettingValue
Window15 minutes
Max requests per IP100
HeadersStandard (RateLimit-*)
Response on limit429 Too Many Requests
json
{
  "success": false,
  "error": "Too many requests, please try again later."
}

Rate limiting is disabled in the test environment to avoid interfering with automated tests.

๐Ÿ“‹ Request Logging โ€‹

HTTP request logging uses Morgan in dev format. Logging is disabled in the test environment.

๐Ÿ” Production Security Tips โ€‹

  • ๐Ÿ”‘ Set a strong, unique JWT_SECRET (at least 32 characters)
  • ๐Ÿ”’ Use HTTPS in production โ€” terminate TLS at your reverse proxy (nginx, Cloudflare, etc.)
  • ๐ŸŒ Restrict CORS_ORIGINS to your actual frontend domains
  • ๐Ÿ“ฆ Keep dependencies updated with npm audit
  • ๐Ÿšฆ Consider increasing rate limits for high-traffic locations or adding per-user limits
  • ๐Ÿงฑ Use a web application firewall (WAF) for additional protection