-
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
Bug: Cors filter can not be used with Shield's Token filter together #9431
Comments
As much as I understand what you want to achieve... this won't be very easy to "fix" as it's not really a bug. By design, when we return the There is a solution for your case. However, it will require you to create a new Something like this: public function before(RequestInterface $request, $arguments = null)
{
if (! str_starts_with($request->getUri()->getPath(), '/api/')) {
return;
}
return parent::before($request, $arguments);
} and similar code for the There is an option to add support in required filters, for URI path pattern recognition or for |
I oppose it. Required Filters are special filters that are applied to every request. |
My question is why in the before filter to process PreflightRequest only, and in the after filter to process normal requests? public array $filters = [
'cors' => [
'before' => ['swagger', 'auth/token', 'api/*'],
],
'tokens' => ['before' => ['api/*']],
]; |
@yonggang-xiao Sorry, I missed that part - it should work. As far as I can imagine, it wouldn't be a breaking change either - at least if developers don't rely on headers being added in the after filter. Does anyone see any drawbacks? |
I'm changing the label back to "bug". Please check the PR: #9437 |
PHP Version
8.2
CodeIgniter4 Version
4.5.7
CodeIgniter4 Installation Method
Composer (using
codeigniter4/appstarter
)Which operating systems have you tested for this bug?
Linux
Which server did you use?
apache
Database
No response
What happened?
When using Cors and Token filter together, if token check failed and return in before filter, the Cors after filter can not running.
Steps to Reproduce
Expected Output
Cors filter should add all headers in before filter, not in after filter.
Anything else?
Cors.php
TokenAuth.php
The text was updated successfully, but these errors were encountered: