-
-
Notifications
You must be signed in to change notification settings - Fork 861
Open
Labels
Description
Current Behavior
Given an URL and visiting it with unsupported method, for instance a GET request to https://demo.flarum.site/login produces message "An error occurred while trying to load this page.". Thrown here:
framework/framework/core/src/Http/Middleware/ResolveRoute.php
Lines 46 to 47 in a46ce07
| case Dispatcher::METHOD_NOT_ALLOWED: | |
| throw new MethodNotAllowedException($method); |
Flarum likely catches it and assumes it to be a generic error instead?
Steps to Reproduce
- Go to https://demo.flarum.site/login, https://demo.flarum.site/register or https://demo.flarum.site/global-logout, etc.
- Observe that the body has "An error occurred while trying to load this page."
Expected Behavior
The body says "Method not allowed." instead of "An error occurred while trying to load this page."
Screenshots
No response
Environment
- Flarum version: 1.8.10
- Website URL: https://demo.flarum.site/ (applicable on any Flarum installation)
- Webserver: nginx
- Hosting environment: shared
- PHP version: 8.3.22
- Browser: Firefox 142.0.1 (aarch64)
Output of php flarum info
No response
Possible Solution
Possibly: catch MethodNotAllowedException and render a body message, e. g. add handlers here(?)
framework/framework/core/src/Foundation/ErrorServiceProvider.php
Lines 41 to 59 in a46ce07
| // 405 Method Not Allowed | |
| 'method_not_allowed' => 405, | |
| // 409 Conflict | |
| 'io_error' => 409, | |
| // 429 Too Many Requests | |
| 'too_many_requests' => 429, | |
| // 503 Service Unavailable | |
| 'maintenance' => 503, | |
| ]; | |
| }); | |
| $this->container->singleton('flarum.error.classes', function () { | |
| return [ | |
| InvalidParameterException::class => 'invalid_parameter', | |
| ModelNotFoundException::class => 'not_found', | |
| ]; |