mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-13 22:15:35 +00:00
fix(subscription): harden quantity updates and proxy trust behavior
Centralize min/max server limits in Stripe quantity updates and wire them into Livewire subscription actions with price preview/update handling. Also improve host/proxy middleware behavior by trusting loopback hosts when FQDN is set and auto-enabling secure session cookies for HTTPS requests behind proxies when session.secure is unset. Includes feature tests for loopback trust and secure cookie auto-detection.
This commit is contained in:
1 parent
76ae720c36
commit
d3b8d70f08
9 files changed
+423
-99
No files matched your search
@@ -91,6 +91,13 @@ class TrustHosts extends Middleware
|
||||
// Trust all subdomains of APP_URL as fallback
|
||||
$trustedHosts[] = $this->allSubdomainsOfApplicationUrl();
|
||||
|
||||
// Always trust loopback addresses so local access works even when FQDN is configured
|
||||
foreach (['localhost', '127.0.0.1', '[::1]'] as $localHost) {
|
||||
if (! in_array($localHost, $trustedHosts, true)) {
|
||||
$trustedHosts[] = $localHost;
|
||||
}
|
||||
}
|
||||
|
||||
return array_filter($trustedHosts);
|
||||
}
|
||||
}
|
||||
@@ -25,4 +25,26 @@ class TrustProxies extends Middleware
|
||||
Request::HEADER_X_FORWARDED_PORT |
|
||||
Request::HEADER_X_FORWARDED_PROTO |
|
||||
Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||
|
||||
/**
|
||||
* Handle the request.
|
||||
*
|
||||
* Wraps $next so that after proxy headers are resolved (X-Forwarded-Proto processed),
|
||||
* the Secure cookie flag is auto-enabled when the request is over HTTPS.
|
||||
* This ensures session cookies are correctly marked Secure when behind an HTTPS
|
||||
* reverse proxy (Cloudflare Tunnel, nginx, etc.) even when SESSION_SECURE_COOKIE
|
||||
* is not explicitly set in .env.
|
||||
*/
|
||||
public function handle($request, \Closure $next)
|
||||
{
|
||||
return parent::handle($request, function ($request) use ($next) {
|
||||
// At this point proxy headers have been applied to the request,
|
||||
// so $request->secure() correctly reflects the actual protocol.
|
||||
if ($request->secure() && config('session.secure') === null) {
|
||||
config(['session.secure' => true]);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user