Hello, I'm with a weird problem that only occurs on my production server, even if I execute the code in development mode.
I have an Auth controller and in the before() function I check I the controller/action that I'm trying to access needs authentication.
I added a log at the begin of this method to investigate this issue.
So, if I try to access http://mydomain/home it checks the authentication and the request is processed without erros, but ~1sec later, my log get two 404 requests. This also happens if I manually type the 404 request that I defined in routes.php
My logs: (The "Ok!" means that the /resource/action does not need authentication)
I don't think so. If I return a string without using assets I have the same "error". And I'm logging inside my Auth controller, so an asset request does not go through the Auth controller.
Why would your 404 action be called if the requested action (in this case 'test') exists, and is called?
Check your webserver log to see it this is caused by external requests. When you request 'test', does that result in a single HTTP GET in your webserver log, or do you see more then one appear?
If it's more then one, check if what is requested actually exists (and is readable by the webserver). If not, it would cause a rewrite to index.php, causing the 404. You can also capture this by logging the entire requested URI instead of only the action.
If not, than it must be caused by your code, but I can't think of anything that could. 404's are handled in FuelPHP by throwing a HttpNotFoundException, and that doesn't easily happen by mistake. This exception is caught in your index.php, and handled there by creating a new Request for the 404 route. You haven't modified the index.php?
That should be there, it's what captures all 404 cases.
The framework will throw a HttpNotFoundException when it encounters a 404 situation, which is then caught in your index.php, and which will fire a new request for the 404 route.
If you remove that, you don't have 404 handling anymore.