zonemaster-gui/config.ts
Marc van der Wal 1a1f739c0f Allow serving the GUI from a subdirectory
In order to support use cases where the GUI is served from a non-root
base URL (i.e. https://zonemaster.example/some/subdirectory instead of
https://zonemaster.example), some modifications were necessary to some
Astro and Svelte files in the project.

I initially tried to keep my modifications to the Apache configuration
files without touching anything else, but I quickly realized that it
couldn’t be done by editing Apache configuration files alone. That is
because the build process assumes that the site is served from a base
directory of / and all HTML files have baked-in absolute URLs.

Fortunately, astro.config.mjs allows setting a base path that can be
easily referred to from Astro and Svelte files. Setting it
fixed *almost* everything: CSS and JS assets load from the right place,
but favicons did not and some link target URLs needed manual adjustment
in order to include the base directory.

I am not familiar with these technologies and there might be a better
approach to some of the edits I’ve made to Astro and Svelte files.

So instead of having to edit the Apache configuration file, one needs to
edit that file and config.ts in order to set the base URL to a
non-default value. This seems to me like an acceptable compromise.
2025-12-15 08:35:37 +01:00

23 lines
674 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import type { Config } from '@/types.ts';
import packageJson from './package.json';
const config: Config = {
defaultLanguage: 'en',
enabledLanguages: ['da', 'en', 'es', 'fi', 'fr', 'nb', 'sv', 'sl'],
baseUrl: import.meta.env.PUBLIC_BASE_URL || '/',
apiBaseUrl: import.meta.env.PUBLIC_API_URL || '/api',
pollingInterval: import.meta.env.PUBLIC_POLLING_INTERVAL || 5000,
clientInfo: {
version: packageJson.version,
id: 'Zonemaster-GUI',
},
siteInfo: {
email: 'contact@zonemaster.net',
siteName: '',
},
setTitle(title: string) {
return `${title} Zonemaster`;
}
};
export default config;