Common Causes

403 vs 401

CodeAuthenticationAuthorisationFix
401Missing/invalidN/AProvide credentials
403Valid (or not required)InsufficientRequest elevated permissions

Server Configuration (Linux/Apache)

# Check file permissions — web server needs read access
chmod 644 /var/www/html/file.html    # files
chmod 755 /var/www/html/directory/   # directories

# .htaccess — block access to sensitive files
<Files "*.env">
  Require all denied
</Files>

# Block directory listing
Options -Indexes

Handling 403 in Your App

// Don't send the user to login on 403 — they ARE logged in
if (res.status === 403) {
  showError('You don't have permission to access this resource.');
  // Optionally redirect to a 403 page
  // window.location.href = '/403';
}