From 406f0095eac8c65a6449500b97d89f3f82d3697d Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Mon, 19 Feb 2024 13:38:38 +0100 Subject: [PATCH] Default ASSET_URL to APP_URL - Fixes #284 --- .env.example | 6 +++--- Dockerfile | 7 ++++--- config/app.php | 6 ++++-- docker/docker-compose.yml | 7 ++++--- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.env.example b/.env.example index f5a60b2b..0fd7c17d 100644 --- a/.env.example +++ b/.env.example @@ -36,10 +36,10 @@ APP_URL=http://localhost # If you want to serve js assets from a CDN (like https://cdn.example.com), -# you need to set this custom URL here. -# Otherwise, this should be the exact same value as APP_URL. +# uncomment the following line and set this var with the CDN url. +# Otherwise, let this line commented. -ASSET_URL=http://localhost +# ASSET_URL=http://localhost # The domain subdirectory from which you want to serve 2FAuth. diff --git a/Dockerfile b/Dockerfile index dc05844c..c6ed307a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -125,9 +125,10 @@ ENV \ # Webauthn won't work otherwise. APP_URL=http://localhost \ # If you want to serve js assets from a CDN (like https://cdn.example.com), - # you need to set this custom URL here. - # Otherwise, this should be the exact same value as APP_URL. - ASSET_URL=http://localhost \ + # uncomment the following line and set this var with the CDN url. + # Otherwise, let this line commented. + # ASSET_URL=http://localhost \ + # # Turn this to true if you want your app to react like a demo. # The Demo mode reset the app content every hours and set a generic demo user. IS_DEMO_APP=false \ diff --git a/config/app.php b/config/app.php index 88fb6364..73fdda48 100644 --- a/config/app.php +++ b/config/app.php @@ -3,6 +3,8 @@ use Illuminate\Support\Facades\Facade; use Illuminate\Support\ServiceProvider; +$appUrl = env('APP_URL', env('HEROKU_APP_NAME') ? 'https://' . env('HEROKU_APP_NAME') . '.herokuapp.com' : 'http://localhost'); + return [ /* @@ -55,9 +57,9 @@ | */ - 'url' => env('APP_URL', env('HEROKU_APP_NAME') ? 'https://' . env('HEROKU_APP_NAME') . '.herokuapp.com' : 'http://localhost'), + 'url' => $appUrl, - 'asset_url' => env('ASSET_URL', null), + 'asset_url' => env('ASSET_URL', $appUrl), /* |-------------------------------------------------------------------------- diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 66cfaf32..e909d975 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -25,9 +25,10 @@ services: # Webauthn won't work otherwise. - APP_URL=http://localhost # If you want to serve js assets from a CDN (like https://cdn.example.com), - # you need to set this custom URL here. - # Otherwise, this should be the exact same value as APP_URL. - - ASSET_URL=http://localhost + # uncomment the following line and set this var with the CDN url. + # Otherwise, let this line commented. + # - ASSET_URL=http://localhost + # # Turn this to true if you want your app to react like a demo. # The Demo mode reset the app content every hours and set a generic demo user. - IS_DEMO_APP=false