the preflight (OPTIONS request) gets rejected. I thought I can handle that (for test purposes) like this:
return [
'debug' => true,
'api' => [
'basicAuth' => true
],
'routes' => [
[
'pattern' => 'api/(:all)',
'method' => 'OPTIONS',
'env' => 'api',
'action' => function ($path = null) {
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: origin, x-requested-with, content-type');
header('Access-Control-Allow-Methods: GET,POST,OPTIONS,DELETE,PUT');
return false;
}
]
],
];
But I get an error 404, with the following:
{
"status": "error",
"exception": "Exception",
"message": "No route found for path: \"pages/notes\" and request method: \"POST\"",
"file": "kirby/src/Http/Router.php",
"line": 120,
"code": 404
}
Any idea?
your route method is set to "OPTIONS"
Обсуждают сегодня