fix: text embed using wrong url

fixes #27, #26 too i think
This commit is contained in:
sylv 2022-10-06 13:26:58 +08:00
parent af01384a1a
commit ec071a47f6
1 changed files with 1 additions and 1 deletions

View File

@ -20,7 +20,7 @@ export const apiUri = isServer ? process.env.API_URL : `/api`;
export async function http(pathOrUrl: string, options?: RequestInit): Promise<Response> {
const hasProtocol = pathOrUrl.startsWith('http');
const isAbsolute = pathOrUrl.startsWith('/');
const url = hasProtocol ? pathOrUrl : isAbsolute ? `${apiUri}${pathOrUrl}` : `${apiUri}/${pathOrUrl}`;
const url = hasProtocol || isAbsolute ? pathOrUrl : `${apiUri}${pathOrUrl}`;
const response = await fetch(url, options);
if (!response.ok) {
const clone = response.clone();