![](/img/trans.png)
[英]Laravel 5.5: route() function in seeder returns wrong route (localhost/ not localhost:8000/)
[英]Laravel route() returns wrong url for localhost
所以我不知道為什么 laravel 的全局函數route()
在 localhost 中使用時會生成錯誤的 URL。
我像這樣使用它route('home:index');
生成的路由是//localhost:3010/home
而不是https://localhost:3010/home
我在瀏覽器中測試了兩個 URL,只有第二個有效。 第一個顯示Your File Was Not Found
錯誤頁面。
我定義的路線如下:
Route::group(['as' => 'home:', 'prefix' => 'home', 'namespace' => 'Home'], function () {
Route::get('/', ['as' => 'index', 'uses' => 'HomeController@index']);
// other routes here.
});
經過進一步調查,當我使用瀏覽器同步時,這只發生在本地主機中。 有沒有辦法配置瀏覽器同步或 Laravel 以返回正確的路由?
P/S :作為附加信息,即使路由生成為//localhost:3010/home
laravel 仍然設法將其重定向到正確的頁面。 但是當我嘗試在 JS 中創建new URL('//localhost:3010/home')
,它返回為無效的 URL。
任何幫助都會很棒。 謝謝
Route::group(['as' => 'home:', 'prefix' => 'home', 'namespace' => 'Home'], function () {
Route::get('/', ['as' => 'index', 'uses' => 'HomeController@index']);
// other routes here.
});
將上面的路由用作route('index')
或將其用作url('/')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.