framework icon indicating copy to clipboard operation
framework copied to clipboard

Text of `MethodNotAllowedException` is not properly rendered in the response body

Open SKevo18 opened this issue 4 months ago • 2 comments

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:

https://github.com/flarum/framework/blob/a46ce07255219093fb6f77e16ea7c7108a5f61aa/framework/core/src/Http/Middleware/ResolveRoute.php#L46-L47

Flarum likely catches it and assumes it to be a generic error instead?

Steps to Reproduce

  1. Go to https://demo.flarum.site/login, https://demo.flarum.site/register or https://demo.flarum.site/global-logout, etc.
  2. 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(?)

https://github.com/flarum/framework/blob/a46ce07255219093fb6f77e16ea7c7108a5f61aa/framework/core/src/Foundation/ErrorServiceProvider.php#L41-L59

Additional Context

Ref.: https://support.freeflarum.com/d/592/2

SKevo18 avatar Sep 16 '25 18:09 SKevo18

@SKevo18 Shall I work on this issue. I have more than 2 years of experience with PHP. I would like to contribute to the community.

Narkunan avatar Sep 22 '25 08:09 Narkunan

Hello ! I also have 2 years of experience with php/laravel can i contribute on this issue too?

ssayres avatar Oct 21 '25 21:10 ssayres