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

@ -22,8 +22,10 @@ if (!config) {
const route = useRoute();
const url = process.client ? config.http.base_url : config.http.url;
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: {
Accept: "application/json",

View file

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