【发布时间】:2021-07-26 06:08:33
【问题描述】:
我用这个代码修改了我的RouteServiceProvider.php:
public function boot()
{
$this->configureRateLimiting();
$this->routes(function () {
// ...
if (env('THEME_NAME') !== null) {
try {
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/client-specific/' . env('THEME_NAME') . '/api.php'));
} catch (\Throwable $th) {
// ...
}
try {
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/client-specific/' . env('THEME_NAME') . '/web.php'));
} catch (\Throwable $th) {
// ...
}
}
});
}
然后在routes/client-specific/' . env('THEME_NAME') . '/web.php文件中我写了这段代码:
<?php
use Illuminate\Support\Facades\Route;
Route::get('{local}/cs/list', [ClientSpecific\CustomController::class, 'listPublic']);
然后我创建了一个php artisan route:list,我在列表中得到了这条路线:
api/{local}/cs/list
在 RouteServiceProvider 中,我为此路由文件使用了 web 中间件。
为什么在我的路由中添加 api/ 前缀?我怎样才能删除它?
谢谢!
=== 更新 ===
我添加了更详细的代码,从Route::prefix('api') 行开始。
【问题讨论】:
标签: laravel laravel-8 laravel-routing