Support the ongoing development of Laravel.io →
Configuration Requests Queues

I have a multi-tenant app. Each client with their own url (client.mycompany.com). When one of those clients' users uploads documents we notify the other users via email with the job queue.

The problem arises when trying to use the route() / any other url method. Because the "request" isn't from the browser it doesn't use the current domain and defaults back to localhost. So emails to clients will show https://localhost/something/here instead of https://client.mycompany.com/something/here

My question is how can inject a "fake" request into laravel to make the URL/Request classes use the url I provide. This would be dynamic based on the email (I know what the tenant/domain is via the record put into the job queue).

Currently I'm cheating by passing the full url into the job itself during the user's runtime. That feels dirty and is sort of a hack instead of injecting a "cli request" that has the url the system should use.

Any advice would be much appreciated.

Last updated 3 years ago.
0

app/config/app.php holds the application url which I think you can set on runtime so that your route() helper will use the correct url (assuming you have some client identifier in your table)

Config::set('app.url', 'https://client.mycompany.com');
Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.