Skip to content

Commit 9abab70

Browse files
author
yaroslav8765
committed
feat: validate ADMIN_BASE_URL and warn when VITE_ADMINFORTH_PUBLIC_PATH is defined in the environment
1 parent 721b556 commit 9abab70

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

adminforth/modules/codeInjector.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,9 @@ class CodeInjector implements ICodeInjector {
894894

895895
const command = 'run dev';
896896
console.log(`⚙️ spawn: npm ${command}...`);
897+
if (process.env.VITE_ADMINFORTH_PUBLIC_PATH) {
898+
console.log('⚠️ Your VITE_ADMINFORTH_PUBLIC_PATH:', process.env.VITE_ADMINFORTH_PUBLIC_PATH, 'has no effect');
899+
}
897900
const env = {
898901
VITE_ADMINFORTH_PUBLIC_PATH: this.adminforth.config.baseUrl,
899902
FORCE_COLOR: '1',

adminforth/modules/configValidator.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,14 @@ export default class ConfigValidator implements IConfigValidator {
853853
if (!newConfig.baseUrl) {
854854
newConfig.baseUrl = '';
855855
}
856+
857+
try {
858+
new URL(newConfig.baseUrl);
859+
errors.push(`⛔️ This url is absolute path: ${newConfig.baseUrl}, you have to use relative paths`);
860+
} catch {
861+
862+
}
863+
856864
if (!newConfig.baseUrl.endsWith('/')) {
857865
newConfig.baseUrlSlashed = `${newConfig.baseUrl}/`;
858866
} else {

0 commit comments

Comments
 (0)