You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As you can see, when I use SimpleRouter::error() in conjunction with Request's setRewriteCallback() method to catch an error route, instead of getting an HTTP status code of 4XX or 5XX, I get 200.
After adding the SimpleRouter::response()->httpCode($e->getCode()); statement, the status code is correct, but the default Nginx interface is displayed instead of the error page that I set.
It seems that all sites that use this Router(include official demo) have this problem.
If you need a more detailed code, reply here.
The text was updated successfully, but these errors were encountered:
In the example above you get a 200 HTTP error because, inside of your error handler, you are just rendering a page through the ErrorManager object and you are never telling php or the router to send a custom HTTP code in the response's header (or at least this is what I think you are [not] doing, given that I don't have the code of ErrorManager). So the default HTTP code sent by php/SimpleRouter will be the 200 code.
On the other hand, in the second part of your question you are instructing the router to use a different HTTP code in the response, and that is working as well, so no issue here.
If follow your view, the code would theoretically work, but it would only end up returning the status code and the page would not be rendered correctly
As you can see, when I use SimpleRouter::error() in conjunction with Request's setRewriteCallback() method to catch an error route, instead of getting an HTTP status code of 4XX or 5XX, I get 200.
Here is my code:
Here
return (new ErrorManager($e))->handle();
returns a normal rendered page.Tried solution: add
SimpleRouter::response()->httpCode($e->getCode());
statementAfter adding the
SimpleRouter::response()->httpCode($e->getCode());
statement, the status code is correct, but the default Nginx interface is displayed instead of the error page that I set.It seems that all sites that use this Router(include official demo) have this problem.
If you need a more detailed code, reply here.
The text was updated successfully, but these errors were encountered: