FOSSology  4.4.0
Open Source License Compliance by Open Source Software
CorsHelper.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2023 Siemens AG
4  SPDX-FileContributor: Gaurav Mishra <mishra.gaurav@siemens.com>
5 
6  SPDX-License-Identifier: GPL-2.0-only
7  */
8 
10 
11 use Psr\Http\Message\ResponseInterface;
12 
14 {
21  public static function addCorsHeaders(ResponseInterface $response): ResponseInterface
22  {
23  global $SysConf;
24  return $response
25  ->withHeader('Access-Control-Allow-Origin', $SysConf['SYSCONFIG']['CorsOrigins'])
26  ->withHeader('Access-Control-Expose-Headers', 'Look-at, X-Total-Pages, Retry-After')
27  ->withHeader('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, Accept, Origin, Authorization, action, accesslevel, active, copyright, Content-Type, description, filename, filesizemax, filesizemin, folderDescription, folderId, folderName, groupName, ignoreScm, applyGlobal, license, limit, name, page, parent, parentFolder, public, reportFormat, searchType, tag, upload, uploadDescription, uploadId, uploadType')
28  ->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS')
29  ->withHeader('Access-Control-Allow-Credentials', 'true');
30  }
31 }
static addCorsHeaders(ResponseInterface $response)
Definition: CorsHelper.php:21
REST api helper classes.