Path Exclusions

Path exclusions allow specific routes to remain accessible during maintenance.

Configuration

// config/curtain.php
'excluded_paths' => [
    // Core system paths
    '_debugbar/*',        // Debug bar
    'horizon/*',          // Laravel Horizon
    'nova/*',             // Laravel Nova
    
    // API endpoints
    'api/*',              // API routes
    'webhook/*',          // Webhooks
    
    // Health checks
    'health',             // Health check endpoint
    'ping',               // Ping endpoint
],

Implementation

// CurtainService.php
public function shouldPassThroughPath(string $path): bool
{
    $excludedPaths = config('curtain.excluded_paths', []);

    // Check exact match
    if (in_array($path, $excludedPaths)) {
        return true;
    }

    // Check wildcard patterns
    foreach ($excludedPaths as $excludedPath) {
        $excludedPath = rtrim((string) $excludedPath, '/');
        $path = rtrim($path, '/');

        if (str_contains($excludedPath, '*')) {
            $pattern = str_replace('*', '.*', $excludedPath);
            if (preg_match('#^'.$pattern.'$#i', $path)) {
                return true;
            }
        }
    }

    return false;
}

Pattern Types

  • Exact match: 'health'

  • Wildcard: 'api/*'

  • Multiple segments: 'api/v1/*'

  • Root path: '/'

Last updated