░▒▓████████████████████████████████▓▒░ ░▒▓█ ▓▒░ ░▒▓█ ~ S W A M P ~ ▓▒░ ░▒▓█ ▓▒░ ░▒▓████████████████████████████████▓▒░
lon105.truehost.cloud
LOCATION:
/home/ilrtztmy/floraandcreations.com/api/Middleware
☗ ROOT
↻ REFRESH
✎ CARVE FLESH
EDITING: CorsMiddleware.php
<?php /** * Flora and Creations — CORS Middleware */ namespace App\Middleware; class CorsMiddleware { /** * Send CORS headers on every request. * * @param string $method HTTP method * @param string $path Request path */ public function __invoke(string $method, string $path): void { $cfg = require __DIR__ . '/../../config/config.php'; $origins = $cfg['cors']['allowed_origins'] ?? ['*']; $methods = implode(', ', $cfg['cors']['allowed_methods'] ?? ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']); $headers = implode(', ', $cfg['cors']['allowed_headers'] ?? ['Content-Type', 'Authorization']); // Determine the allowed origin $requestOrigin = $_SERVER['HTTP_ORIGIN'] ?? ''; $allowedOrigin = '*'; if (!in_array('*', $origins) && !empty($requestOrigin) && in_array($requestOrigin, $origins)) { $allowedOrigin = $requestOrigin; } header("Access-Control-Allow-Origin: $allowedOrigin"); header("Access-Control-Allow-Methods: $methods"); header("Access-Control-Allow-Headers: $headers"); header('Access-Control-Max-Age: 86400'); header('Access-Control-Allow-Credentials: true'); // For OPTIONS preflight, respond immediately if ($method === 'OPTIONS') { http_response_code(204); exit; } } }
CANCEL
Name
Type
Size
Modified
Actions
↩ ..
DIR
—
—
📄 AuthMiddleware.php
PHP
2.3 KB
2026-07-15 09:17
EDIT
📄 CorsMiddleware.php
PHP
1.4 KB
2026-07-15 09:17
EDIT