Fixes for different base_url and bind url

This commit is contained in:
Jesse Wierzbinski 2024-04-09 02:05:54 -10:00
parent 8ec34f7138
commit 27260dff68
No known key found for this signature in database
4 changed files with 18 additions and 22 deletions

View file

@ -50,10 +50,6 @@ export default defineNuxtConfig({
titleSeparator: "·", titleSeparator: "·",
siteName: "Lysand", siteName: "Lysand",
trailingSlash: true, trailingSlash: true,
// @ts-ignore
url2: async () => await Promise.resolve("cheese"),
//url: `${config?.http.bind}:${config?.http.bind_port}`,
}, },
}, },
site: { site: {

View file

@ -22,8 +22,10 @@ if (!config) {
const route = useRoute(); const route = useRoute();
const url = process.client ? config.http.base_url : config.http.url;
const data = await fetch( const data = await fetch(
new URL(`/api/v1/statuses/${route.params.uuid}`, config.http.url), new URL(`/api/v1/statuses/${route.params.uuid}`, url),
{ {
headers: { headers: {
Accept: "application/json", Accept: "application/json",

View file

@ -22,30 +22,26 @@ if (!config) {
const route = useRoute(); const route = useRoute();
const url = process.client ? config.http.base_url : config.http.url;
const username = (route.params.username as string).replace("@", ""); const username = (route.params.username as string).replace("@", "");
const id = await fetch( const id = await fetch(new URL(`/api/v1/accounts/search?q=${username}`, url), {
new URL(`/api/v1/accounts/search?q=${username}`, config.http.url), headers: {
{ Accept: "application/json",
headers: {
Accept: "application/json",
},
}, },
) })
.then((res) => res.json()) .then((res) => res.json())
.catch(() => null); .catch(() => null);
let data = null; let data = null;
if (id && id.length > 0) { if (id && id.length > 0) {
data = await fetch( data = await fetch(new URL(`/api/v1/accounts/${id[0].id}`, url), {
new URL(`/api/v1/accounts/${id[0].id}`, config.http.url), headers: {
{ Accept: "application/json",
headers: {
Accept: "application/json",
},
}, },
) })
.then((res) => res.json()) .then((res) => res.json())
.catch(() => ({ .catch(() => ({
error: "Failed to fetch user (it probably doesn't exist)", error: "Failed to fetch user (it probably doesn't exist)",

View file

@ -107,9 +107,11 @@ if (!config) {
throw new Error("Config not found"); throw new Error("Config not found");
} }
const instanceInfo = (await fetch( const url = process.client ? config.http.base_url : config.http.url;
new URL("/api/v1/instance", config.http.url),
).then((data) => data.json())) as APIInstance & { const instanceInfo = (await fetch(new URL("/api/v1/instance", url)).then(
(data) => data.json(),
)) as APIInstance & {
tos_url: string; tos_url: string;
}; };