- Added CORS preflight handling

This commit is contained in:
Dave Mc Nicoll committed 2025-09-12 19:38:53 +00:00
1 parent 5d6d7ff49c
commit c5ec582bd1
3 files changed
+56

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
<?php
namespace Lean\Api\Middleware;
use Laminas\Diactoros\Response\JsonResponse;
use Lean\Factory\HttpFactory;
use Picea\Ui\Method\FormHandler;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Lean\Api\{Factory\DebugFormFactoryInterface, Form, Entity};
class CORS implements MiddlewareInterface {
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
{
var_dump($request->getMethod() );
if ($request->getMethod() === "option") {
die("an option :)");
}
return $handler->handle($request);
}
}