URL generation (front&back) + fixed authJWT for SSR
This commit is contained in:
18
client/lib/utils.js
vendored
18
client/lib/utils.js
vendored
@@ -13,3 +13,21 @@ export const hash = (str, seed = 0) => {
|
||||
|
||||
return 4294967296 * (2097151 & h2) + (h1 >>> 0);
|
||||
}
|
||||
|
||||
export const appUrl = (path = '/') => {
|
||||
let baseUrl = useRuntimeConfig().public.appUrl
|
||||
if (!baseUrl) {
|
||||
console.warn('appUrl not set in runtimeConfig')
|
||||
return path
|
||||
}
|
||||
|
||||
if (path.startsWith('/')) {
|
||||
path = path.substring(1)
|
||||
}
|
||||
|
||||
if (!baseUrl.endsWith('/')) {
|
||||
baseUrl += '/'
|
||||
}
|
||||
|
||||
return baseUrl + path
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user