Skip to content

Commit 1aad884

Browse files
authored
fix to 2.0
1 parent b3e73c6 commit 1aad884

File tree

1 file changed

+39
-9
lines changed

1 file changed

+39
-9
lines changed

App/Models/CORS.php

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,46 @@ class CORS
1212
private $maxAge = 0;
1313
private $allowCredentials = false;
1414

15-
// Constructor to set CORS settings when creating a new instance of the class
16-
public function __construct($allowedOrigins = array(), $allowedMethods = array(), $allowedHeaders = array(), $exposedHeaders = array(), $maxAge = 0, $allowCredentials = false)
15+
// Method to set allowed origins
16+
public function origin($origins)
1717
{
18-
// Set the allowed origins, methods, headers, exposed headers, max age, and allow credentials properties
19-
$this->allowedOrigins = $allowedOrigins;
20-
$this->allowedMethods = $allowedMethods;
21-
$this->allowedHeaders = $allowedHeaders;
22-
$this->exposedHeaders = $exposedHeaders;
23-
$this->maxAge = $maxAge;
24-
$this->allowCredentials = $allowCredentials;
18+
$this->allowedOrigins = $origins;
19+
return $this;
20+
}
21+
22+
// Method to set allowed methods
23+
public function methods($methods)
24+
{
25+
$this->allowedMethods = $methods;
26+
return $this;
27+
}
28+
29+
// Method to set allowed headers
30+
public function headers($headers)
31+
{
32+
$this->allowedHeaders = $headers;
33+
return $this;
34+
}
35+
36+
// Method to set exposed headers
37+
public function expose($headers)
38+
{
39+
$this->exposedHeaders = $headers;
40+
return $this;
41+
}
42+
43+
// Method to set max age
44+
public function maxAge($age)
45+
{
46+
$this->maxAge = $age;
47+
return $this;
48+
}
49+
50+
// Method to set allow credentials
51+
public function credentials($credentials)
52+
{
53+
$this->allowCredentials = $credentials;
54+
return $this;
2555
}
2656

2757
// Method to set CORS headers based on the properties set in the constructor

0 commit comments

Comments
 (0)