Skip to content

Commit 568b4ee

Browse files
committed
feat: prefix the route with api subdomain
1 parent 75879ff commit 568b4ee

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

app/App/Shared/Providers/RouteServiceProvider.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Illuminate\Routing\Router;
1111
use Illuminate\Support\Facades\RateLimiter;
1212
use OpenApi\Attributes as OA;
13+
use Illuminate\Contracts\Config\Repository as ConfigRepository;
1314

1415
#[OA\Info(
1516
version: 'v1.0',
@@ -138,15 +139,21 @@ public function boot(): void
138139
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
139140
});
140141

141-
$this->routes(function (Router $router) {
142+
/** @var ConfigRepository $configRepository */
143+
$configRepository = $this->app->get(ConfigRepository::class);
144+
145+
$this->routes(function (Router $router) use ($configRepository) {
142146
$router->middleware('api')
147+
->domain($configRepository->get('app.domain'))
143148
->group(base_path('routes/api.php'));
144149

145150
$router->middleware('api')
146151
->prefix('v1')
152+
->domain($configRepository->get('app.domain'))
147153
->group(base_path('routes/api/v1.php'));
148154

149155
$router->middleware('web')
156+
->domain($configRepository->get('app.domain'))
150157
->group(base_path('routes/web.php'));
151158
});
152159
}

0 commit comments

Comments
 (0)