Skip to content

Commit

Permalink
fix api baseURL for 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 ada4ea6 commit 2c03d56
Showing 1 changed file with 3 additions and 1 deletion.
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

0 comments on commit 2c03d56

Please sign in to comment.