-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add CORS filter #8649
feat: add CORS filter #8649
Conversation
2a3cb63
to
4dfb2d0
Compare
3712869
to
86ee415
Compare
Now the CORS filter always adds (1) Plain OPTIONS request (CORS filter does not handle)
(2) Invalid preflight request (CORS filter does not handle)
(3) Normal preflight request (CORS filter does handle)
(1) and (2) are cached (if there is an intermediate cache to cache them) and the cached (2) will be returned to the request (3). So the current implementation is not good. (Added) |
…eablility instead of `Vary: Origin`. See codeigniter4#8649 (comment)
…eablility instead of `Vary: Origin`. See codeigniter4#8649 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice feature - well documented.
* | ||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age | ||
*/ | ||
'maxAge' => 7200, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is your criteria for choosing this number by default? Laravel assumes 0
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the same as session expiration.
I think the CORS config is not often changed, so it may be better to be longer.
// ... | ||
public array $filters = [ | ||
// ... | ||
'cors' => [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to use a different configuration (exactly like ['filter' => 'cors:api']
)? If yes, please document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is documented in the Filters page.
https://codeigniter4.github.io/CodeIgniter4/incoming/filters.html#filter-arguments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a link. 3a7e880
Also, this is easier to read.
It was difficult to read when running phpunit --testdox
For better readablitiy.
…eablility instead of `Vary: Origin`. See codeigniter4#8649 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks.
@yasinpalizban, This PR may be interesting for you.
Access-Control-Allow-Headers not working |
Description
Cors
filter classHTTP\Cors
classChecklist: