Ibon Azkoitia
Ibon Azkoitia
FFilament
Created by Ibon Azkoitia on 5/5/2024 in #❓┊help
Mapping a custom domain for redirections (url shortener)
The thing is that I'm not expert with servers, but I defend myself with API. So I manage to make it work that way In the handleRegistration function I added the Http::put and worked fine
16 replies
FFilament
Created by Ibon Azkoitia on 5/5/2024 in #❓┊help
Mapping a custom domain for redirections (url shortener)
So, when a new Project is created, I suppose I can send a POST request to add the new custom_domain
16 replies
FFilament
Created by Ibon Azkoitia on 5/5/2024 in #❓┊help
Mapping a custom domain for redirections (url shortener)
So, it seams the option is to use the Forge API to add aliases: https://forge.laravel.com/api-documentation#add-site-aliases
16 replies
FFilament
Created by Ibon Azkoitia on 5/5/2024 in #❓┊help
Mapping a custom domain for redirections (url shortener)
It seems that Forge creates a file so not configured domains do not work https://forge.laravel.com/docs/sites/the-basics.html#protecting-against-unconfigured-domains I moved the file to parent folder and removed the alias for the extra domain and still works. Will try to add another domain to test it if just with DNS change works. Also, if this works, I suppose have to add a functionality (on the route) to find if that domain is in the Database so I limit (me, not Forge) which domain works. Important if you are reading this: I'm not a developer, maybe I'm doing awful things.
16 replies
FFilament
Created by Ibon Azkoitia on 5/5/2024 in #❓┊help
Mapping a custom domain for redirections (url shortener)
It works! Without SSL for now » https://ibon.tech/dudvf0 https gives an error, will search more info about it Edit: now works with SSL also. will update this thread if I manage to automate things so other people can see it
16 replies
FFilament
Created by Ibon Azkoitia on 5/5/2024 in #❓┊help
Mapping a custom domain for redirections (url shortener)
No description
16 replies
FFilament
Created by Ibon Azkoitia on 5/5/2024 in #❓┊help
Mapping a custom domain for redirections (url shortener)
I'm using Laravel Forge + DigitalOcean In settings I see and it's activated the "Allow Wildcard Sub-Domains" but I don't see option for custom domains that users may add.
16 replies
FFilament
Created by Ibon Azkoitia on 5/5/2024 in #❓┊help
Mapping a custom domain for redirections (url shortener)
Hello Dennis, thank you for your reply. Well, I'm not saying it's an error per se. I just don't know how to handle that situation. I will add realistic data so it's easier for examples: - Project domain: prolinks .pro - Project Filament Admin: prolinks .pro/app/ - Tenant Admin Url: prolinks .pro/app/ibontech - Tenant custom domain field: ibon .tech - Ibon .tech edit DNS A record to = Server IP where the project is located Situation 1 » Creating a url with the slug "dudvf0" - Example "prolinks .pro/dudvf0" (you can try it) - It works, it redirects to "productividad .pro" - Not the use case I'm looking for, I want users to use their own custom domain Situation 2 » Creating a url with the slug "dudvf0" - Example "ibon .tech/dudvf0" (you can try it) - It doesn't work, domain gives error "ERR_EMPTY_RESPONSE" Routes code for the fallback using the "prolinks .pro" base url before slug
Route::fallback(function (string $slug) {
$url = Link::where('slug', $slug)->firstOrFail();

if (!isset($url->url)) {
abort(404);
} else {
// Generate the final URL.
$final_url = LinkResource::getFinalUrl($url->url, $url->utm_source, $url->utm_medium, $url->utm_campaign_name);

return redirect($final_url);
}

});
Route::fallback(function (string $slug) {
$url = Link::where('slug', $slug)->firstOrFail();

if (!isset($url->url)) {
abort(404);
} else {
// Generate the final URL.
$final_url = LinkResource::getFinalUrl($url->url, $url->utm_source, $url->utm_medium, $url->utm_campaign_name);

return redirect($final_url);
}

});
public static function getFinalUrl($url, $utm_source, $utm_medium, $utm_campaign_name): string
{
$final_url = '';

if ($utm_source) {
$final_url = $url . '?utm_source=' . $utm_source;
}

if ($utm_medium) {
$final_url = $final_url . '&utm_medium=' . $utm_medium;
}

if ($utm_campaign_name) {
$final_url = $final_url . '&utm_campain=' . $utm_campaign_name;
}

if ( empty($final_url)) {
$final_url = $url;
}

return $final_url;
}
public static function getFinalUrl($url, $utm_source, $utm_medium, $utm_campaign_name): string
{
$final_url = '';

if ($utm_source) {
$final_url = $url . '?utm_source=' . $utm_source;
}

if ($utm_medium) {
$final_url = $final_url . '&utm_medium=' . $utm_medium;
}

if ($utm_campaign_name) {
$final_url = $final_url . '&utm_campain=' . $utm_campaign_name;
}

if ( empty($final_url)) {
$final_url = $url;
}

return $final_url;
}
I'm not an expert developer, so maybe I'm not explaining myself correctly. Thank you!
16 replies