Fix custom base URL support

This commit is contained in:
Bubka 2023-01-25 16:58:30 +01:00
parent 05eafe51ac
commit dcc6579365
5 changed files with 21 additions and 7 deletions

View File

@ -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.

View File

@ -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',

View File

@ -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', ''),
],
/*

2
resources/js/api.js vendored
View File

@ -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;
}

View File

@ -17,7 +17,7 @@
<link rel="apple-touch-icon-precomposed" href="{{ asset('favicon_lg.png') }}" />
<link rel="manifest" href="/manifest.json">
<link href=".{{ mix('css/app.css') }}" rel="stylesheet">
<link href="{!! $subdirectory !!}{{ mix('css/app.css') }}" rel="stylesheet">
</head>
<body class="has-text-lighter">
<div id="app">
@ -31,8 +31,8 @@
var isTestingApp = {!! $isTestingApp !!};
var appLocales = {!! $locales !!};
</script>
<script src=".{{ mix('js/manifest.js') }}"></script>
<script src=".{{ mix('js/vendor.js') }}"></script>
<script src=".{{ mix('js/app.js') }}"></script>
<script src="{!! $subdirectory !!}{{ mix('js/manifest.js') }}"></script>
<script src="{!! $subdirectory !!}{{ mix('js/vendor.js') }}"></script>
<script src="{!! $subdirectory !!}{{ mix('js/app.js') }}"></script>
</body>
</html>