Skip to content

Commit

Permalink
specify api domain
Browse files Browse the repository at this point in the history
  • Loading branch information
Wirewraith committed Dec 7, 2024
1 parent 80dd988 commit d814dc3
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/Api/TestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TestController extends Controller
public function index(Request $request)
{
return response()->json([
'message' => 'This is a test',
'message' => app(\Swoole\Http\Server::class)->stats(1),
]);
}
}
2 changes: 1 addition & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function boot()
});

Scramble::routes(function (Route $route) {
return $route->getDomain() === 'api.'.preg_replace('(^https?://)', '', config('app.url'));
return $route->getDomain() === config('app.api_url');
});

Event::listen(function (\SocialiteProviders\Manager\SocialiteWasCalled $event) {
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function boot()

$this->routes(function () {
Route::middleware('api')
->domain('api.'.preg_replace('(^https?://)', '', config('app.url')))
->domain(config('app.api_url'))
->group(base_path('routes/api.php'));

Route::middleware('web')
Expand Down
4 changes: 3 additions & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@

'url' => env('APP_URL', 'http://localhost'),

'asset_url' => env('ASSET_URL'),
'api_url' => env('API_URL', 'http://api.localhost'),

'asset_url' => env('ASSET_URL', 'http://localhost'),

/*
|--------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion config/scramble.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Your API domain. By default, app domain is used. This is also a part of the default API routes
* matcher, so when implementing your own, make sure you use this config if needed.
*/
'api_domain' => 'api.goonhub.test',
'api_domain' => config('app.api_url'),

'info' => [
/*
Expand Down

0 comments on commit d814dc3

Please sign in to comment.