php - Laravel route() 为 localhost 返回错误的 url
问题描述
所以我不知道为什么 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.
});
经过进一步调查,当我使用浏览器同步时,这只发生在 localhost 中。有没有办法配置浏览器同步或 laravel 以返回正确的路由?
P/S:作为附加信息,即使生成为//localhost:3010/home
laravel 的路由仍然设法将其重定向到正确的页面。但是当我尝试new URL('//localhost:3010/home')
在 JS 中创建时,它返回为无效的 URL。
任何帮助都会很棒。谢谢
解决方案
Route::group(['as' => 'home:', 'prefix' => 'home', 'namespace' => 'Home'], function () {
Route::get('/', ['as' => 'index', 'uses' => 'HomeController@index']);
// other routes here.
});
将上述路线用作route('index')
或将其用作url('/')
推荐阅读
- visual-studio-2010 - 配置 Bamboo 以使用 MS Build Xaml 模板
- android - NotificationListenerService 不适用于环聊
- python - 带有来自validated_data的kwargs的Django Rest Framework update()
- amazon-web-services - 通过 route53 到本地的 HTTPS
- java - java.lang.NoClassDefFoundError:解析失败:Lcom/google/android/gms/common/internal/zzbq Nearby Place App
- javascript - 使用 HTML 和 JavaScript 的逻辑门
- ios - 归档 CocoaPods 依赖项以发布到 App Store 时出错
- excel - 根据匹配数据从一个文档复制/粘贴到另一个文档
- python - 安装诱变 pip 时出现 UnicodeDecodeError
- parsing - 如何在三地址码中表示二进制逻辑