-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Forms: FileUpload - Image preview on subdomain #12648
Conversation
Maybe it's better to simplify it more to The filename is not needed here. What do you think? |
I think the current solution is good and changes are not necessary, thanks |
Before I merge this, I just wanted to check to see if there is an easier solution. You're using the |
You're right. Your middleware idea works fine. You just missed the disc segment in the dot path. :) Guess, this class SubdomainMiddleware
{
public function handle(Request $request, Closure $next): Response
{
// Handle subdomain ...
config()->set('filesystems.disks.public.url', url("/storage"));
return $next($request);
}
} |
To be honest, I disagree there, it's not really a concern of Filament how you have your filesystems set up, so I don't think it's our responsibility to document |
Description
This PR for the FileUpload field adds support for image previews on subdomains.
In a multi-tenant application, tenants have their subdomains, e.g. "https://tenent1.site.test".
If a user on this subdomain uploads an image in a filament-form, the preview will not work because the URL from APP_URL is used, e.g. "https://www.site.test".
The method
->getUploadedFileUrlUsing(fn (string $file): string => url("/{$file}"))
allows to set the current domain, instead of the one stored in APP_URL.From the updated documentation: "Set a different base URL"
By default, uploaded files are served from the domain specified in the APP_URL set in your .env file. If your multitenant application uses subdomains, you can set the current subdomain URL using the `getUploadedFileUrlUsing' callback.
Functional changes
composer cs
command.