pixelfed/app/Providers/AppServiceProvider.php
Luke Watts d1dca5a1f1
fix: add opt of forceScheme(https)
When running the application locally with
APP_URL=http://localhost it is unexpected for
all route URLs returned by `route('route-name')`
to use the https prefix.

Configuring SSL for your local environment should
not be a required step to development locally.

The new logic checks the configured URL for presence
of https:// OR that this the application is running
in a production environment.
2022-10-23 15:09:32 +02:00

70 lines
1.4 KiB
PHP

<?php
namespace App\Providers;
use App\Observers\{
AvatarObserver,
LikeObserver,
NotificationObserver,
ModLogObserver,
ProfileObserver,
StatusHashtagObserver,
StatusObserver,
UserObserver,
UserFilterObserver,
};
use App\{
Avatar,
Like,
Notification,
ModLog,
Profile,
StatusHashtag,
Status,
User,
UserFilter
};
use Auth, Horizon, URL;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
use Illuminate\Pagination\Paginator;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
if (preg_match("/^https/", env('APP_URL')) || env('APP_ENV') === 'production') {
URL::forceScheme('https');
}
Schema::defaultStringLength(191);
Paginator::useBootstrap();
Avatar::observe(AvatarObserver::class);
Like::observe(LikeObserver::class);
Notification::observe(NotificationObserver::class);
ModLog::observe(ModLogObserver::class);
Profile::observe(ProfileObserver::class);
StatusHashtag::observe(StatusHashtagObserver::class);
User::observe(UserObserver::class);
Status::observe(StatusObserver::class);
UserFilter::observe(UserFilterObserver::class);
Horizon::auth(function ($request) {
return Auth::check() && $request->user()->is_admin;
});
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}