Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting route url from queue returns wrong base

Tags:

queue

laravel

When I'm sending a queued mail message from a laravel queue the route urls always return localhost instead of the url set in config app.url. The rest of the site works fine but just urls generated from the queue are wrong.

like image 653
Morgan O'Neal Avatar asked Feb 06 '15 19:02

Morgan O'Neal


1 Answers

The url in app.php is only used when Laravel runs as a console application. Your URLs where created using the domain name the application runs under: localhost

You can fix this by only generating a relative URL and then prepend the domain name from the config:

$url = Config::get('app.url') . route('route-name', null, false);

(The third argument to route() is $absolute = true. By setting that to false you get a relative URL starting with /)

like image 117
lukasgeiter Avatar answered Dec 08 '22 01:12

lukasgeiter