何をしているか
https://www.hypertextcandy.com/vue-laravel-tutorial-authentication-part-4/
上記サイトを参考にLaravel × Vue のアプリ開発の勉強をしています
ただ、Laravelの更新により、現在のバージョンではコピペでエラーが出てしまうことがありました。
躓いた箇所
上記サイトのところで、api.phpにgetを渡したのにも関わらず、web.phpの
Route::get('/{any?}', fn() => view('index'))->where('any', '.+');
が参照されてしまいました。
解決策
app\Providers\RouteServiceProvider.php の箇所で
public function boot()
{
$this->configureRateLimiting();
$this->routes(function () {
Route::middleware('web')
->group(base_path('routes/web.php'));
Route::prefix('api')
->middleware('web')
->group(base_path('routes/api.php'));
});
}
となっている箇所を
public function boot()
{
$this->configureRateLimiting();
$this->routes(function () {
Route::prefix('api')
->middleware('web')
->group(base_path('routes/api.php'));
Route::middleware('web')
->group(base_path('routes/web.php'));
});
}
に変更しました。
要するにwebとapi の読み込む順番を逆にするということです。
同じところで躓いた人は試してみてください。