mirror of
https://github.com/versia-pub/frontend.git
synced 2026-03-13 03:29:16 +01:00
refactor: 🎨 Move Lysand-FE into its own repository
This commit is contained in:
commit
f6989707f4
26 changed files with 1226 additions and 0 deletions
19
composables/useConfig.ts
Normal file
19
composables/useConfig.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
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 await fetch(new URL("/api/_fe/config", host)).then((res) =>
|
||||
res.json(),
|
||||
);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue