If Ziggy’sDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/tighten/ziggy/llms.txt
Use this file to discover all available pages before exploring further.
route() helper generates URLs with an http scheme when your application uses https, the issue is likely related to TLS/SSL termination or proxy configuration.
The Problem
When your application is behind a load balancer, proxy, or uses TLS/SSL termination, Laravel may not correctly detect that the original request used HTTPS. This causes Ziggy to generate URLs with the wrong scheme:Common Scenarios
This issue typically occurs when:- Using a reverse proxy (like Nginx or Apache) that handles SSL/TLS
- Behind a load balancer (AWS ELB, Cloudflare, etc.)
- Hosted on platforms like Heroku, Laravel Forge, or AWS Elastic Beanstalk
- Using TLS/SSL termination
Solution: Configure Trusted Proxies
Laravel includes a middleware for configuring trusted proxies. Follow these steps to fix the scheme detection:Locate the TrustProxies middleware
The middleware is located at:If it doesn’t exist, you can create it or publish it from Laravel’s middleware.
Configure the proxies property
Set the
$proxies property to trust your proxy or load balancer. For most cases, you can trust all proxies:Verify middleware is registered
Ensure the middleware is registered in your Laravel 10 and earlier:
bootstrap/app.php or app/Http/Kernel.php (depending on your Laravel version):Laravel 11+:Platform-Specific Configuration
AWS Elastic Load Balancer
For AWS ELB, ensure theHEADER_X_FORWARDED_AWS_ELB header is included:
Cloudflare
Cloudflare adds its own headers. Trust Cloudflare’s IP ranges:Heroku
Heroku handles SSL termination. Trust all proxies:Laravel Forge with Nginx
Forge’s default Nginx configuration forwards the correct headers. Simply trust all proxies:Environment-Specific Settings
For different configurations per environment, use environment variables:.env files:
Verifying APP_URL Configuration
Ensure yourAPP_URL in .env uses HTTPS:
Troubleshooting
Still Getting HTTP URLs?
Check request headers
Check request headers
Verify that proxy headers are being sent. Add temporary debugging:Expected output:
Proxy not sending headers
Proxy not sending headers
If your proxy isn’t sending the correct headers, configure it to do so.Nginx example:Apache example:
Force HTTPS in config
Force HTTPS in config
As a last resort, force HTTPS in your Note: This should be a last resort. Properly configuring trusted proxies is the recommended approach.
AppServiceProvider:Mixed Content Warnings
If you’re getting mixed content warnings in the browser:- Ensure all assets use HTTPS
- Check that
ASSET_URLin.envuses HTTPS:
- Use protocol-relative URLs or Laravel’s
secure_asset()helper
Testing Locally with HTTPS
To test HTTPS locally:-
Use Laravel Valet (macOS):
- Use Laravel Herd (macOS/Windows): HTTPS is enabled by default
- Use Laragon (Windows): Enable SSL in the Laragon menu