14four/laravel-force-https
Laravel middleware package to force HTTPS across your app. Automatically redirects HTTP requests to HTTPS, with options to exclude paths or environments so you can keep local/testing flexible while enforcing secure connections in production.
ForceHttpsMiddleware) integrates seamlessly with Laravel’s built-in middleware stack (e.g., web, api).app.example.com vs. staging.example.com), which is valuable for multi-environment deployments (dev/stage/prod). The ability to exclude routes (e.g., /health) via middleware priority or annotations is a plus.TrustProxies, RedirectIfAuthenticated) should be tested for precedence issues.web vs. api middleware groups).Handle class (e.g., dynamic HTTPS enforcement based on request headers).RedirectIfAuthenticated). Requires testing with existing middleware.301 redirect logic doesn’t bottleneck response times.http://api.example.com vs. https://app.example.com).X-Forwarded-Proto must be trusted. The package supports this via TrustProxies integration, but misconfiguration could lead to infinite redirects.localhost) where HTTPS enforcement may break tools like Laravel Valet or Docker.config/force_https.php overrides).TrustProxies, Subdomain) that could interfere with this package’s redirects?TrustProxies configured correctly to avoid redirect loops in cloud environments (e.g., AWS ALB, Heroku)?/health, /webhooks) should bypass HTTPS enforcement, and how will they be excluded?301 redirects)?TrustProxies.return 301).app/Http/Kernel.php) for HTTPS-related logic.composer require 14four/laravel-force-https
php artisan vendor:publish --provider="14four\ForceHttps\ForceHttpsServiceProvider"
app/Http/Kernel.php to include the middleware in the appropriate groups (e.g., $middlewareGroups['web']).config/force_https.php for environment-specific rules (e.g., exclude localhost).301 status codes).curl -v http://example.com).Illuminate\Foundation\Application middleware binding changes.illuminate/support) are version-locked to Laravel’s requirements.TrustProxies, Localization). Test precedence by adjusting middleware order in Kernel.php.ForceHttpsMiddleware after TrustProxiesMiddleware (if used) to ensure correct protocol detection.RedirectIfAuthenticated).localhost and internal domains from HTTPS enforcement.Kernel.php and use feature flags for environment-specific configs.Monolog) to detect misconfigurations early.\Log::debug('HTTPS redirect failed for ' . request()->fullUrl(), ['user_agent' => request()->userAgent()]);
TrustProxies is configured correctly and that the package isn’t running in a loop with server-level redirects.Asset helper or mix-manifest.json.301 redirect doesn’t become a bottleneck (unlikely, but test under load).301 redirects (e.g., from crawlers). Consider rate-limiting or caching redirect responses.How can I help you explore Laravel packages today?