Skip to content

Commit

Permalink
configureUrlSchema
Browse files Browse the repository at this point in the history
  • Loading branch information
lao9s committed Mar 9, 2023
1 parent 092bdaf commit 755bfe5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Str;

class RouteServiceProvider extends ServiceProvider
{
Expand All @@ -26,6 +28,8 @@ public function boot(): void
{
$this->configureRateLimiting();

$this->configureUrlSchema();

$this->routes(function () {
Route::middleware('api')
->prefix('api')
Expand All @@ -36,6 +40,19 @@ public function boot(): void
});
}

protected function configureUrlSchema():void
{
$appUrl = config("app.url");

if (!empty($appUrl)) {
$schema = Str::before($appUrl, ':');

if(in_array($schema, ['http','https'])) {
URL::forceScheme($schema);
}
}
}

/**
* Configure the rate limiters for the application.
*/
Expand Down

0 comments on commit 755bfe5

Please sign in to comment.