How do I force HTTPS in Taskify?
Answer: Configure HTTPS enforcement in your AppServiceProvider or server configuration to ensure all traffic is encrypted.
Laravel Configuration:
In your AppServiceProvider.php:
use Illuminate\Support\Facades\URL;
public function boot()
{
if (config('app.env') === 'production') {
URL::forceScheme('https');
}
}Server-Level Configuration:
Apache (.htaccess):
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]Nginx:
server {
listen 80;
server_name your-domain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name your-domain.com;
# SSL configuration here
}Environment Configuration:
Set these in your .env file:
APP_URL=https://your-domain.com
FORCE_HTTPS=trueAdditional Security Headers:
Add security headers to your application:
// In AppServiceProvider boot method
$response->headers->set('Strict-Transport-Security', 'max-age=31536000; includeSubDomains');
$response->headers->set('X-Content-Type-Options', 'nosniff');
$response->headers->set('X-Frame-Options', 'DENY');
$response->headers->set('X-XSS-Protection', '1; mode=block');Verification:
After implementing HTTPS enforcement:
- Test HTTP to HTTPS redirection
- Verify SSL certificate is valid
- Check for mixed content warnings
- Test all application functionality