mirror of
https://github.com/versia-pub/frontend.git
synced 2025-12-06 16:38:20 +01:00
27 lines
629 B
TypeScript
27 lines
629 B
TypeScript
export const useConfig = async () => {
|
|
let host =
|
|
useRequestHeader("X-Forwarded-Host") ??
|
|
useRuntimeConfig().public.apiHost;
|
|
|
|
if (!host?.includes("http")) {
|
|
// On server, this will be some kind of localhost
|
|
host = `http://${host}`;
|
|
}
|
|
|
|
if (!host) {
|
|
throw createError({
|
|
statusCode: 500,
|
|
statusMessage: "No X-Forwarded-Host header found",
|
|
});
|
|
}
|
|
|
|
return {
|
|
http: {
|
|
url: host,
|
|
base_url: host,
|
|
},
|
|
}; /* await fetch(new URL("/api/_fe/config", host)).then((res) =>
|
|
res.json(),
|
|
); */
|
|
};
|