Reorganize FE

This commit is contained in:
Jesse Wierzbinski 2024-04-13 19:26:29 -10:00
parent e27a80c40a
commit 354493133c
No known key found for this signature in database
10 changed files with 112 additions and 63 deletions

View file

@ -0,0 +1,29 @@
export const useConfig = async () => {
let host = useRequestHeader("X-Forwarded-Host");
if (!host && process.server) {
host = process.env.BUILD_HOST;
}
if (!host?.includes("http")) {
// On server, this will be some kind of localhost
host = `http://${host}`;
}
if (process.client) {
host = useRequestURL().origin.toString();
}
console.log(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(),
);
};