Support HTTP OPTIONS requests
This commit is contained in:
parent
bb60ed4094
commit
58a513cb30
2 changed files with 17 additions and 5 deletions
|
@ -265,6 +265,16 @@ class Module
|
||||||
$logger->debug('index.php: page not found.', ['request_uri' => $server['REQUEST_URI'], 'address' => $server['REMOTE_ADDR'], 'query' => $server['QUERY_STRING']]);
|
$logger->debug('index.php: page not found.', ['request_uri' => $server['REQUEST_URI'], 'address' => $server['REMOTE_ADDR'], 'query' => $server['QUERY_STRING']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($server['REQUEST_METHOD'] === Router::OPTIONS) {
|
||||||
|
header('HTTP/1.1 204 No Content');
|
||||||
|
header('access-control-allow-credentials: true');
|
||||||
|
header('access-control-allow-headers: Authorization,Content-Type');
|
||||||
|
header('access-control-allow-methods: ' . implode(',', Router::ALLOWED_METHODS));
|
||||||
|
header('access-control-allow-origin: *');
|
||||||
|
header('access-control-max-age: 86400');
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
$placeholder = '';
|
$placeholder = '';
|
||||||
|
|
||||||
$profiler->set(microtime(true), 'ready');
|
$profiler->set(microtime(true), 'ready');
|
||||||
|
|
|
@ -44,11 +44,12 @@ use Friendica\Network\HTTPException;
|
||||||
*/
|
*/
|
||||||
class Router
|
class Router
|
||||||
{
|
{
|
||||||
const DELETE = 'DELETE';
|
const DELETE = 'DELETE';
|
||||||
const GET = 'GET';
|
const GET = 'GET';
|
||||||
const PATCH = 'PATCH';
|
const PATCH = 'PATCH';
|
||||||
const POST = 'POST';
|
const POST = 'POST';
|
||||||
const PUT = 'PUT';
|
const PUT = 'PUT';
|
||||||
|
const OPTIONS = 'OPTIONS';
|
||||||
|
|
||||||
const ALLOWED_METHODS = [
|
const ALLOWED_METHODS = [
|
||||||
self::DELETE,
|
self::DELETE,
|
||||||
|
@ -56,6 +57,7 @@ class Router
|
||||||
self::PATCH,
|
self::PATCH,
|
||||||
self::POST,
|
self::POST,
|
||||||
self::PUT,
|
self::PUT,
|
||||||
|
self::OPTIONS
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var RouteCollector */
|
/** @var RouteCollector */
|
||||||
|
|
Loading…
Reference in a new issue