Use database branding for PWA manifest
This commit is contained in:
1 parent
0231c468a4
commit
ea76ef29ba
4 files changed
+36
No files matched your search
@@ -17,4 +17,5 @@ export async function refreshBranding() {
|
||||
if (!response.ok) throw new Error('Unable to load branding')
|
||||
Object.assign(branding, await response.json() as AppBranding)
|
||||
document.title = branding.productName
|
||||
document.querySelector('meta[name="description"]')?.setAttribute('content', branding.description)
|
||||
}
|
||||
@@ -92,6 +92,20 @@ export default defineConfig(({ mode }) => {
|
||||
],
|
||||
},
|
||||
}),
|
||||
{
|
||||
name: 'runtime-branding-manifest',
|
||||
enforce: 'post',
|
||||
transformIndexHtml: {
|
||||
order: 'post',
|
||||
handler(html: string) {
|
||||
if (isCapacitor) return html
|
||||
const apiBase = (env.VITE_API_BASE_URL || '/api').replace(/\/$/, '')
|
||||
// A manifest hosted on another origin cannot safely use this site's start URL and scope.
|
||||
if (!apiBase.startsWith('/') || apiBase.startsWith('//')) return html
|
||||
return html.replace(/(<link\s+rel="manifest"\s+href=")[^"]+("\s*\/?>)/, `$1${escapeHtml(apiBase)}/business-settings/manifest.webmanifest$2`)
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
base: isCapacitor ? './' : '/',
|
||||
build: {
|
||||
|
||||
Reference in new issue
Block a user