jeudi 5 novembre 2015

Queued route() urls has wrong domain in URL

I have a Laravel 5.1 application that has many clients with their own unique subdomains and databases.

On app loading, my middlewares resolves the client and sets the app.url (config/app.php) accordingly. It all works great, in the browser. All urls generated by route() has the correct subdomain for current client.

But, stuff queued (Redis in my case) will always defaults to a domain URL of "localhost".

So if I send a welcome email where the text template contains route('account') it will from the queue generate a "http://localhost/account" URL. This is of course not correct.

Info: For each Queued command (closure) I have, I always send with it who the client is that's queing. That way I set the client before the queued command is fired. It loads the right database connection. But changing the default route() server name appears rather difficult!

I've experimented with extending the UrlGenerator class, but it appears that this is completely ignored for queued commands and only works on HTTP requests.

I've also tried adding this before the queues command is fired: app('url')->forceRootUrl($client->getClientUrl()); It did not work. (but works with HTTP requests)

Anyone here have an idea for how to set my own default domain for route() in CLI mode?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire