laravel / cashier-stripe

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.
https://laravel.com/docs/billing
MIT License
2.37k stars 667 forks source link

Cashier routes should have "web" middleware #1695

Closed dansleboby closed 1 month ago

dansleboby commented 1 month ago

Cashier Stripe Version

15.4.1

Laravel Version

11.15.0

PHP Version

8.3.5

Database Driver & Version

No response

Description

https://github.com/laravel/cashier-stripe/blob/15.x/src/CashierServiceProvider.php#L105

I think it should have like

'middleware' => 'web'

In the group since it load the as web.php in laravel witch load this default middleware group

Steps To Reproduce

Not required

crynobone commented 1 month ago

Hi there,

Thanks for reporting the problem you are encountering, but it looks like this is a question which may be better suited for a support channel. We only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repository you can try one of the following channels:

However, this issue will not be locked and everyone is still free to discuss solutions to your problem!

Thanks.

dansleboby commented 1 month ago

An inconsistency in the way middleware is applied across different Laravel packages. In the Laravel Passport package, middleware is included in the route definitions:

https://github.com/laravel/passport/blob/11.x/routes/web.php#L14C5-L14C27

'middleware' => 'web',

and

https://github.com/laravel/passport/blob/11.x/routes/web.php#L19C1-L19C26

Route::middleware(['web', ...]);

However, in the Laravel Cashier package, specifically in the registerRoutes method, the middleware is missing:

https://github.com/laravel/cashier-stripe/blob/15.x/src/CashierServiceProvider.php#L102C24-L102C38

This is the issue I encountering. To maintain consistency and ensure proper functionality, it might be worth considering adding the web middleware in the Cashier routes. This would align it with the practices seen in other Laravel packages, such as Passport.