X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=index.php;h=9c1e4999ed68ef717142b66b4511403918ed8eb6;hb=5d9bc40d7e48b8ac4829f9101f85b849d9199fa3;hp=925d47a5e476b55260e9cda84fbfa33e554b66cc;hpb=75c4b0d03b6e9a4323675091dbfa664a1bd006eb;p=github%2Fshaarli%2FShaarli.git diff --git a/index.php b/index.php index 925d47a5..9c1e4999 100644 --- a/index.php +++ b/index.php @@ -1635,9 +1635,9 @@ function buildLinkList($PAGE, $LINKSDB, $conf, $pluginManager, $loginManager) uasort($taglist, 'strcasecmp'); $link['taglist'] = $taglist; - // Thumbnails enabled, not a note, + // Logged in, thumbnails enabled, not a note, // and (never retrieved yet or no valid cache file) - if ($thumbnailsEnabled && $link['url'][0] != '?' + if ($loginManager->isLoggedIn() && $thumbnailsEnabled && $link['url'][0] != '?' && (! isset($link['thumbnail']) || ($link['thumbnail'] !== false && ! is_file($link['thumbnail']))) ) { $elem = $LINKSDB[$keys[$i]]; @@ -1858,6 +1858,7 @@ $app->group('/api/v1', function() { })->add('\Shaarli\Api\ApiMiddleware'); $response = $app->run(true); + // Hack to make Slim and Shaarli router work together: // 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) { @@ -1865,5 +1866,12 @@ if ($response->getStatusCode() == 404 && strpos($_SERVER['REQUEST_URI'], '/api/v header('Content-Type: text/html; charset=utf-8'); renderPage($conf, $pluginManager, $linkDb, $history, $sessionManager, $loginManager); } 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); }