Skip to content

Commit

Permalink
Support Subpath
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Jogeleit <frank.jogeleit@lovoo.com>
  • Loading branch information
Frank Jogeleit committed Apr 9, 2024
1 parent 35e72a1 commit 658cb4a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion frontend/modules/core/plugins/apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import {cluster, create} from '~/modules/core/api'
import {useConfigStore} from "~/store/config";
import {type Config, DisplayMode} from "~/modules/core/types";

const trimSlashes = (str: string) => str.split('/').filter(p => !!p).join('/')

export default defineNuxtPlugin(async () => {
const config = useRuntimeConfig()
const api = create({ baseURL: config.public.coreApi as string, prefix: cluster.value })
const api = create({ baseURL: config.public.coreApi || `//${window.location.host}/${trimSlashes(window.location.pathname)}`, prefix: cluster.value })

const apiConfig = await api.config().catch((error): Config => {
console.error(`failed to load config: ${error}`)
Expand Down
5 changes: 3 additions & 2 deletions frontend/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default defineNuxtConfig({
},
},
app: {
baseURL: process.env.NODE_ENV === 'production' ? '.' : '/',
head: {
title: 'Policy Reporter UI',
htmlAttrs: {
Expand All @@ -51,8 +52,8 @@ export default defineNuxtConfig({
{ name: 'format-detection', content: 'telephone=no' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
{ rel: 'icon', type: 'image/x-icon', href: './favicon.ico' }
]
}
}
},
})

0 comments on commit 658cb4a

Please sign in to comment.