blob: 12deaecddbeaed36b623e9b5441bd7c4fa8d78b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
<?php
namespace OCA\Passman\Middleware;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\Response;
use \OCP\AppFramework\Middleware;
use OCP\IRequest;
class APIMiddleware extends Middleware {
private $request;
public function __construct(IRequest $request) {
$this->request = $request;
}
public function afterController($controller, $methodName, Response $response) {
if($response instanceof JSONResponse){
if(isset($this->request->server['HTTP_ORIGIN'])) {
$response->addHeader('Access-Control-Allow-Origin', $this->request->server['HTTP_ORIGIN']);
}
}
return parent::afterController($controller, $methodName, $response);
}
}
|