diff --git a/src/components/molecules/Heading.svelte b/src/components/molecules/Heading.svelte index 7955929..b737425 100644 --- a/src/components/molecules/Heading.svelte +++ b/src/components/molecules/Heading.svelte @@ -1,12 +1,13 @@
-

{text}

+ +

+ {text} +

\ No newline at end of file diff --git a/src/utils/api.ts b/src/utils/api.ts index 43c1ac1..da3859c 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -1,4 +1,5 @@ -const apiURL: string = process.env.NODE_ENV === 'development' +// Define API URL from environment +export const API_URL = import.meta.env.MODE === 'development' ? `${import.meta.env.VITE_API_URL_DEV}` : `${import.meta.env.VITE_API_URL_PROD}` @@ -8,7 +9,7 @@ const apiURL: string = process.env.NODE_ENV === 'development' */ export const fetchAPI = async (query: string) => { try { - const res = await fetch(`${apiURL}${import.meta.env.VITE_API_GRAPHQL_PATH}`, { + const res = await fetch(`${API_URL}${import.meta.env.VITE_API_GRAPHQL_PATH}`, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index 52bc268..54792d2 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -1,3 +1,6 @@ +import { API_URL } from '$utils/api' + + /** * Get a Directus asset URL from parameters */ @@ -15,5 +18,5 @@ export const getAssetUrl = ( if (quality) args += `&quality=${quality}` if (format) args += `&format=${format}` - return `${import.meta.env.VITE_API_URL_DEV}/assets/${id}?width=${width}&height=${height}&fit=${fit}${args}` + return `${API_URL}/assets/${id}?width=${width}&height=${height}&fit=${fit}${args}` } \ No newline at end of file