commit 71a7438f2c0247b42e44fd28d85f50fa97eb3268
parent 716b93f4bf9cbf8980ea73e929f015e184e816d2
Author: ctucx <leah@antifa.jetzt>
Date: Sat, 27 Jun 2020 20:23:08 +0200
parent 716b93f4bf9cbf8980ea73e929f015e184e816d2
Author: ctucx <leah@antifa.jetzt>
Date: Sat, 27 Jun 2020 20:23:08 +0200
fix cors
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/public/dav.php b/public/dav.php @@ -8,6 +8,19 @@ ini_set('memory_limit', '1024M'); define("PATH", __DIR__.'/'); date_default_timezone_set('Europe/Berlin'); +if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') { + // return only the headers and not the content + // only allow CORS if we're doing a GET - i.e. no saving for now. + if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']) && + $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'] == 'GET') { + header('Access-Control-Allow-Origin: *'); + header('Access-Control-Allow-Headers: X-Requested-With'); + } + exit; +} else { + header("Access-Control-Allow-Origin: *"); +} + if (!file_exists('vendor/')) { die('<h1>Incomplete installation</h1>Dependencies have not been installed.'); } @@ -72,4 +85,4 @@ $server->addPlugin(new FilesPlugin\Plugin(PATH.'data/files/')); //Fancy Web $server->addPlugin(new Sabre\DAV\Browser\Plugin()); -$server->exec();- \ No newline at end of file +$server->exec();