not sure you can do it at that point (in the bootstrap), because the app doesn't exist yet. as a workaround you should be OK to create a custom cors middleware wrapper and skip the middleware there when the environment is local.
i mean like this:
in the bootstrap
->withMiddleware(function (Middleware $middleware) {
$middleware->replace(
HandleCors::class, \App\Http\Middleware\CustomHandleCors::class
);
})//...
and the CustomHandleCors middleware:
<?php
namespace App\Http\Middleware;
use Closure;
use Fruitcake\Cors\CorsService;
use Illuminate\Contracts\Container\Container;
class CustomHandleCors extends \Illuminate\Http\Middleware\HandleCors
{
public function __construct(Container $container, CorsService $cors)
{
if (!app()->environment('local')) {
parent::__construct($container, $cors);
}
}
public function handle($request, Closure $next)
{
if (!app()->environment('local')) {
return parent::handle($request, $next);
}
return $next($request);
}
}
but there might be something to configure it more laravel way, someone more experienced with L11 can point to right direction. until then you could be fine with the custom wrapper.
or just keep the CORS middleware like it is, just change the CORS configuration when running on local (change the published config/cors.php to get values from env and set it differently for local and production)