Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Need to specify middleware and path for /mails endpoint #8

Closed
baoc75 opened this issue Dec 28, 2024 · 4 comments · Fixed by #9
Closed

[Bug]: Need to specify middleware and path for /mails endpoint #8

baoc75 opened this issue Dec 28, 2024 · 4 comments · Fixed by #9
Assignees
Labels
bug Something isn't working

Comments

@baoc75
Copy link

baoc75 commented Dec 28, 2024

What happened?

I expect to see the email preview

Additionally, since this is part of internal admin panel, I expect the route path should starts with /admin and is protected with middleware. I think we should allow exporting routes. In my case, I am building a multi-tenant app that has middleware to decide which database to use.

This issue affect all areas that call to /mails endpoint.

How to reproduce the bug

When I go to admin/mails and the modal show up, I press on Preview tab and it show the errors
image

Error traces: https://flareapp.io/share/J7oXaod5

Package Version

1.0.5

PHP Version

8.3.4

Laravel Version

11.32.0

Which operating systems does with happen with?

Windows

Notes

No response

@baoc75 baoc75 added the bug Something isn't working label Dec 28, 2024
@baoc75 baoc75 changed the title [Bug]: Can't preview emails [Bug]: Can't preview emails Attempt to read property "html" on null Dec 28, 2024
@baoc75 baoc75 changed the title [Bug]: Can't preview emails Attempt to read property "html" on null [Bug]: Can't preview emails Attempt to read property "html" on null as well as other actions Dec 28, 2024
@baoc75 baoc75 changed the title [Bug]: Can't preview emails Attempt to read property "html" on null as well as other actions [Bug]: Need to specify middleware and path for /mails endpoint Dec 28, 2024
@Baspa Baspa self-assigned this Dec 28, 2024
@markvaneijk
Copy link
Member

Not sure what the best practice is for a Filament package. Also not sure if this is possible:

  • Add the current panel path to the route URL
  • Add the defined panel middleware to the routes

We’ll probably find out.

@baoc75 curious what you mean with “exporting routes” or how you see the solution.

@Baspa
Copy link
Member

Baspa commented Jan 2, 2025

Adding the current panel path to the url should be possible using some of the methods like Filament::getTenant() I guess. About the panel middleware I'm not sure because I don't know if the Filament tenant is already available in the service provider. @markvaneijk

@Baspa Baspa linked a pull request Jan 3, 2025 that will close this issue
@Baspa Baspa closed this as completed in #9 Jan 3, 2025
@Baspa
Copy link
Member

Baspa commented Jan 3, 2025

Protecting your routes by middleware or tenant routes is now described here @baoc75 :

https://github.com/vormkracht10/filament-mails?tab=readme-ov-file#tenant-middleware--route-protection

It's also possible to add the routes to your own routes file (e.g. web.php) and add the middleware there:

// routes\web.php

use Vormkracht10\FilamentMails\Facades\FilamentMails;

FilamentMails::routes();

This is a breaking change so we made it available at version v2.0.0.

@baoc75
Copy link
Author

baoc75 commented Jan 3, 2025

Awesome thank you! I am gonna implement it now @Baspa @markvaneijk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants