Files
ladill-mini/app/Http/Middleware/RedirectLegacyQrToLadillLink.php
T
isaacclad 42257ab444
Deploy Ladill Mini / deploy (push) Successful in 57s
Fix Mini Pay sheet: same-origin pay URL and visible chrome.
Cross-origin fetch to ladl.link had no CORS, so showSheet never ran. Open the sheet immediately and keep Paystack behind the Continue CTA.
2026-07-21 18:46:26 +00:00

32 lines
897 B
PHP

<?php
namespace App\Http\Middleware;
use App\Support\LadillLink;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class RedirectLegacyQrToLadillLink
{
public function handle(Request $request, Closure $next): Response
{
if (! preg_match('#^q/[a-z0-9]#i', ltrim($request->path(), '/'))) {
return $next($request);
}
if (LadillLink::isInternalRequest($request)) {
return $next($request);
}
// Same-origin AJAX from Mini-hosted payment pages (e.g. mini.ladill.com)
// must hit local /q/{code}/pay — redirecting to ladl.link breaks CORS and
// the checkout sheet never opens.
if ($request->ajax() || $request->expectsJson() || $request->wantsJson()) {
return $next($request);
}
return LadillLink::legacyRedirect($request);
}
}