From 3a91a6b84b54c8b20ecb42b8c854f770b962a0d7 Mon Sep 17 00:00:00 2001 From: binsky Date: Thu, 15 Jun 2023 20:40:05 +0200 Subject: [PATCH] fix middleware location and namespace --- {middleware => lib/Middleware}/APIMiddleware.php | 6 ++++-- {middleware => lib/Middleware}/ShareMiddleware.php | 0 2 files changed, 4 insertions(+), 2 deletions(-) rename {middleware => lib/Middleware}/APIMiddleware.php (82%) rename {middleware => lib/Middleware}/ShareMiddleware.php (100%) diff --git a/middleware/APIMiddleware.php b/lib/Middleware/APIMiddleware.php similarity index 82% rename from middleware/APIMiddleware.php rename to lib/Middleware/APIMiddleware.php index 12deaecd..d099868f 100644 --- a/middleware/APIMiddleware.php +++ b/lib/Middleware/APIMiddleware.php @@ -4,7 +4,7 @@ namespace OCA\Passman\Middleware; use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\Response; -use \OCP\AppFramework\Middleware; +use OCP\AppFramework\Middleware; use OCP\IRequest; class APIMiddleware extends Middleware { @@ -19,7 +19,9 @@ class APIMiddleware extends Middleware { if($response instanceof JSONResponse){ if(isset($this->request->server['HTTP_ORIGIN'])) { $response->addHeader('Access-Control-Allow-Origin', $this->request->server['HTTP_ORIGIN']); - } + } else { + $response->addHeader('Access-Control-Allow-Origin', '*'); + } } return parent::afterController($controller, $methodName, $response); } diff --git a/middleware/ShareMiddleware.php b/lib/Middleware/ShareMiddleware.php similarity index 100% rename from middleware/ShareMiddleware.php rename to lib/Middleware/ShareMiddleware.php