parent
5de61c2ca7
commit
5d9bc40d7e
1 changed files with 8 additions and 0 deletions
|
@ -1858,6 +1858,7 @@ function install($conf, $sessionManager, $loginManager) {
|
||||||
})->add('\Shaarli\Api\ApiMiddleware');
|
})->add('\Shaarli\Api\ApiMiddleware');
|
||||||
|
|
||||||
$response = $app->run(true);
|
$response = $app->run(true);
|
||||||
|
|
||||||
// Hack to make Slim and Shaarli router work together:
|
// Hack to make Slim and Shaarli router work together:
|
||||||
// If a Slim route isn't found and NOT API call, we call renderPage().
|
// If a Slim route isn't found and NOT API call, we call renderPage().
|
||||||
if ($response->getStatusCode() == 404 && strpos($_SERVER['REQUEST_URI'], '/api/v1') === false) {
|
if ($response->getStatusCode() == 404 && strpos($_SERVER['REQUEST_URI'], '/api/v1') === false) {
|
||||||
|
@ -1865,5 +1866,12 @@ function install($conf, $sessionManager, $loginManager) {
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
renderPage($conf, $pluginManager, $linkDb, $history, $sessionManager, $loginManager);
|
renderPage($conf, $pluginManager, $linkDb, $history, $sessionManager, $loginManager);
|
||||||
} else {
|
} else {
|
||||||
|
$response = $response
|
||||||
|
->withHeader('Access-Control-Allow-Origin', '*')
|
||||||
|
->withHeader(
|
||||||
|
'Access-Control-Allow-Headers',
|
||||||
|
'X-Requested-With, Content-Type, Accept, Origin, Authorization'
|
||||||
|
)
|
||||||
|
->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
||||||
$app->respond($response);
|
$app->respond($response);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue