为什么route('charts.inline', 123123)
返回http://localhost/charts/123123
而不是我的实际域?我的ENV config/app.php url设置正确,并且我的ENV是正确的。我正在通过终端[一个"命令"]执行这项表彰。
想法?
您已经回答了自己的问题:
我正在通过终端[命令]运行此推荐
当您在终端上运行时,不需要计算主机名,因此框架假定localhost
为默认值。
如果您想在从命令行运行代码时将默认域名设置为正常工作,请转到您的config/app.php
文件并从更改以下设置:
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/
'url' => 'http://localhost',
至
'url' => 'http://yourdomain.com',
我刚刚在Laravel 5上测试了这个程序,但我希望它在Laraver 4上也适用。
如果在配置中设置url
后仍然存在此问题,请确保您的URL具有协议,即https:''example.com
而不是example.com
,否则它将不起作用。