diff --git a/.env.example b/.env.example index 7c4bd0bd..ad8b714a 100644 --- a/.env.example +++ b/.env.example @@ -32,6 +32,17 @@ APP_KEY=SomeRandomStringOf32CharsExactly APP_URL=http://localhost +# The domain subdirectory from which you want to serve 2FAuth. +# This must reflect the path targeted by APP_URL. +# +# For example, if you set APP_URL=https://mydomain.org/2fa to access 2FAuth from the '/2fa/' subdirectory +# you have to set APP_SUBDIRECTORY=2fa +# +# Leave blank if you serve 2FAuth from the domain root. + +APP_SUBDIRECTORY= + + # 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. diff --git a/app/Http/Controllers/SinglePageController.php b/app/Http/Controllers/SinglePageController.php index 9de5bbea..15c5f180 100644 --- a/app/Http/Controllers/SinglePageController.php +++ b/app/Http/Controllers/SinglePageController.php @@ -17,13 +17,16 @@ public function index() { event(new ScanForNewReleaseCalled()); + $subdir = config('2fauth.config.appSubdirectory') ? '/' . config('2fauth.config.appSubdirectory') : ''; + return view('landing')->with([ 'appSettings' => Settings::all()->toJson(), 'appConfig' => collect([ 'proxyAuth' => config('auth.defaults.guard') === 'reverse-proxy-guard' ? true : false, 'proxyLogoutUrl' => config('2fauth.config.proxyLogoutUrl') ? config('2fauth.config.proxyLogoutUrl') : false, - 'subdirectory' => '/' . config('2fauth.config.appSubdirectory') . '/', + 'subdirectory' => $subdir, ])->toJson(), + 'subdirectory' => $subdir, 'lang' => App::currentLocale(), 'isDemoApp' => config('2fauth.config.isDemoApp') ? 'true' : 'false', 'isTestingApp' => config('2fauth.config.isTestingApp') ? 'true' : 'false', diff --git a/config/2fauth.php b/config/2fauth.php index 86049d61..8468b3ad 100644 --- a/config/2fauth.php +++ b/config/2fauth.php @@ -26,7 +26,7 @@ 'isTestingApp' => env('IS_TESTING_APP', false), 'trustedProxies' => env('TRUSTED_PROXIES', null), 'proxyLogoutUrl' => env('PROXY_LOGOUT_URL', null), - 'appSubdirectory' => env('APP_SUBDIR', ''), + 'appSubdirectory' => env('APP_SUBDIRECTORY', ''), ], /* diff --git a/resources/js/api.js b/resources/js/api.js index a7da2bc2..ece1e633 100644 --- a/resources/js/api.js +++ b/resources/js/api.js @@ -8,7 +8,7 @@ Vue.use(VueAxios, axios) Vue.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; Vue.axios.defaults.headers.common['Content-Type'] = 'application/json' -if (window.appConfig.APP_SUBDIRECTORY) { +if (window.appConfig.subdirectory) { Vue.axios.defaults.baseURL = window.appConfig.subdirectory; } diff --git a/resources/views/landing.blade.php b/resources/views/landing.blade.php index da632d58..11aad303 100644 --- a/resources/views/landing.blade.php +++ b/resources/views/landing.blade.php @@ -17,7 +17,7 @@ - +
@@ -31,8 +31,8 @@ var isTestingApp = {!! $isTestingApp !!}; var appLocales = {!! $locales !!}; - - - + + + \ No newline at end of file