在AWS弹性Beanstalk中找不到Laravel API路由



我使用的是Laravel 8,我的应用程序托管在AWS Elastic Beanstalk中。所有路由(路由/web(都工作正常,但API中的路由(路由/API(显示未找到。路由API在本地主机中运行正常,这是Elastic beanstalle或EC2中的问题,因为它所在的主机不允许访问这些API路由。有人有解决方案吗?服务器在Apache中,指向/public。

RouteServiceProvider.php

use IlluminateCacheRateLimitingLimit;
use IlluminateFoundationSupportProvidersRouteServiceProvider as ServiceProvider;
use IlluminateHttpRequest;
use IlluminateSupportFacadesRateLimiter;
use IlluminateSupportFacadesRoute;
class RouteServiceProvider extends ServiceProvider
{
/**
* The path to the "home" route for your application.
*
* This is used by Laravel authentication to redirect users after login.
*
* @var string
*/
public const HOME = '/home';
/**
* The controller namespace for the application.
*
* When present, controller route declarations will automatically be prefixed with this namespace.
*
* @var string|null
*/
// protected $namespace = 'App\Http\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
$this->configureRateLimiting();
$this->routes(function () {
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
});
}
/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
});
}
}

运行以下命令:

>> php artisan auth:clear-resets
>> php artisan cache:clear
>> php artisan config:clear
>> php artisan event:clear
>> php artisan optimize:clear
>> php artisan route:cache
>> php artisan view:clear
>> php artisan config:clear                            
>> php artisan view:clear                              
>> npm run dev                                         
>> php artisan key:generate 
>> php artisan optimize   

最新更新