Skip to content
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

Missing Feature, routes are empty when trying route_to in filters #9328

Open
crustamet opened this issue Dec 17, 2024 · 1 comment
Open

Missing Feature, routes are empty when trying route_to in filters #9328

crustamet opened this issue Dec 17, 2024 · 1 comment

Comments

@crustamet
Copy link
Contributor

I do not know if this is a wanted behaviour or not

But having this Filter Config for example

public array $globals = [
	'before' => [
		'honeypot' => ['except' => [route_to('some_alias')]],
		// 'csrf',
		// 'invalidchars',
	],
	'after' => [
		// 'honeypot',
		// 'secureheaders',
	],
];

first it does not allow you to have it as a constant with dynamic strings

so i change the filter config with this addition instead of putting in the globals

public function __construct()
{
	$routes = Services::routes();
	
	echo route_to('some_alias'); 

	$this->globals['before']['honeypot']['except'] = [route_to('route_alias')];
}

It does not work because routes are not loaded yet from the Codeigniter->Run() method because of this piece of code here
https://github.com/codeigniter4/CodeIgniter4/blob/develop/system/CodeIgniter.php#L346

The handling of the request happens after the filters were loaded....

The filters are loaded first then the routes configuration file ... why is that ?
I thought that routes were important without them nothing works, i know there is an AutoRouteImprove feature or what not. even though routes should be already loaded here no ?

I just want to access my routes that i have defined in the filters configuration file...

Is there a way to do this ?

@crustamet
Copy link
Contributor Author

crustamet commented Dec 17, 2024

i have moved the handling of the request before the filters are loaded and for sure now i can see my defined routes from my routes config file...

I'm sure that this is not the right approach..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant