From 1670da55e957a0b7e2cef40c5d7e5b9f56ef5aac Mon Sep 17 00:00:00 2001 From: asayee Date: Mon, 15 Dec 2025 10:01:45 -0400 Subject: [PATCH] Testing prefix forwarding configs to fix livewire upload bug --- app/Http/Middleware/ApplyForwardedPrefix.php | 35 ++++++++++++++++++++ bootstrap/app.php | 9 ++++- hosp.conf | 15 +++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 app/Http/Middleware/ApplyForwardedPrefix.php create mode 100644 hosp.conf diff --git a/app/Http/Middleware/ApplyForwardedPrefix.php b/app/Http/Middleware/ApplyForwardedPrefix.php new file mode 100644 index 0000000..0c1b84c --- /dev/null +++ b/app/Http/Middleware/ApplyForwardedPrefix.php @@ -0,0 +1,35 @@ +server->get('REQUEST_URI'); // includes query string + if (is_string($uri) && $uri !== '' && !str_starts_with($uri, $prefix . '/')) { + $request->server->set('REQUEST_URI', $prefix . $uri); + } + + // Help Symfony compute the base URL. + $scriptName = $request->server->get('SCRIPT_NAME') ?: ''; + if ($scriptName !== '' && !str_starts_with($scriptName, $prefix . '/')) { + $request->server->set('SCRIPT_NAME', $prefix . $scriptName); + } + } + + return $next($request); + } +} diff --git a/bootstrap/app.php b/bootstrap/app.php index 5f49160..9f09e91 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -3,6 +3,7 @@ use Illuminate\Foundation\Application; use Illuminate\Foundation\Configuration\Exceptions; use Illuminate\Foundation\Configuration\Middleware; +use Illuminate\Http\Request; return Application::configure(basePath: dirname(__DIR__)) ->withRouting( @@ -12,7 +13,13 @@ ) ->withMiddleware(function (Middleware $middleware) { // - $middleware->trustProxies(at: '172.16.121.9'); + $middleware->trustProxies( + at: '*', // or ['127.0.0.1', '::1'] / your proxy IP(s) + headers: Request::HEADER_X_FORWARDED_FOR | + Request::HEADER_X_FORWARDED_HOST | + Request::HEADER_X_FORWARDED_PORT | + Request::HEADER_X_FORWARDED_PROTO + );; }) ->withExceptions(function (Exceptions $exceptions): void { // diff --git a/hosp.conf b/hosp.conf new file mode 100644 index 0000000..6e4f4e5 --- /dev/null +++ b/hosp.conf @@ -0,0 +1,15 @@ +Listen 25120 + + + ServerName jedi.msya.gov.tt + DocumentRoot /var/www/html/hosp_2025/public + + + AllowOverride All + Require all granted + Options FollowSymLinks + + + ErrorLog /var/log/httpd/hosp_2025_error.log + CustomLog /var/log/httpd/hosp_2025_access.log combined + \ No newline at end of file