aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php8
1 files changed, 8 insertions, 0 deletions
diff --git a/index.php b/index.php
index 4b86a3e2..9c1e4999 100644
--- a/index.php
+++ b/index.php
@@ -1858,6 +1858,7 @@ $app->group('/api/v1', function() {
1858})->add('\Shaarli\Api\ApiMiddleware'); 1858})->add('\Shaarli\Api\ApiMiddleware');
1859 1859
1860$response = $app->run(true); 1860$response = $app->run(true);
1861
1861// Hack to make Slim and Shaarli router work together: 1862// Hack to make Slim and Shaarli router work together:
1862// If a Slim route isn't found and NOT API call, we call renderPage(). 1863// If a Slim route isn't found and NOT API call, we call renderPage().
1863if ($response->getStatusCode() == 404 && strpos($_SERVER['REQUEST_URI'], '/api/v1') === false) { 1864if ($response->getStatusCode() == 404 && strpos($_SERVER['REQUEST_URI'], '/api/v1') === false) {
@@ -1865,5 +1866,12 @@ if ($response->getStatusCode() == 404 && strpos($_SERVER['REQUEST_URI'], '/api/v
1865 header('Content-Type: text/html; charset=utf-8'); 1866 header('Content-Type: text/html; charset=utf-8');
1866 renderPage($conf, $pluginManager, $linkDb, $history, $sessionManager, $loginManager); 1867 renderPage($conf, $pluginManager, $linkDb, $history, $sessionManager, $loginManager);
1867} else { 1868} else {
1869 $response = $response
1870 ->withHeader('Access-Control-Allow-Origin', '*')
1871 ->withHeader(
1872 'Access-Control-Allow-Headers',
1873 'X-Requested-With, Content-Type, Accept, Origin, Authorization'
1874 )
1875 ->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
1868 $app->respond($response); 1876 $app->respond($response);
1869} 1877}