Laravel auth:api middleware does not work with newly created route files
<p>I have a web application using Laravel 7. On the application, I recently created a new api.php file under a folder called <code>api/v2</code> (<code>routes/api/v2/api.php< /code>). The problem I am facing is that in the newly created api.php file the 'auth:api' middleware is not working. </p>
<p>I checked the request headers and found that the <code>authorization</code> header for these routes was empty. With the old routing files, everything works fine. </p>
<p>I have registered the new api file in RouteServiceProvider.php as shown below</p>
<pre class="brush:php;toolbar:false;">Route::prefix('api/v2')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api/v2/api.php'));</pre>
<p>Except for the authentication issue, all routing is working fine without any issues. Since I cannot call the '$request->user()' method inside the controller. </p>
<p>PS: I am using apache 2.4 </p>
<p>Does anyone know why this is happening? </p>