diff --git a/.github/workflows/sst.dev.yml b/.github/workflows/sst.dev.yml index 0ae06a9..1b438d9 100644 --- a/.github/workflows/sst.dev.yml +++ b/.github/workflows/sst.dev.yml @@ -36,6 +36,7 @@ jobs: Deploy: needs: Test runs-on: ubuntu-latest + environment: Development env: NEXT_PUBLIC_API_URL: ${{ vars.NEXT_PUBLIC_API_URL }} NEXT_PUBLIC_FEATURE_FLAG_UNRELEASED: ${{ vars.NEXT_PUBLIC_FEATURE_FLAG_UNRELEASED }} diff --git a/config/index.ts b/config/index.ts index f93049a..568e018 100644 --- a/config/index.ts +++ b/config/index.ts @@ -1,10 +1,13 @@ -const DOMAIN_NAME: string = "sgmotortrends.com"; +const DOMAIN_NAME = "sgmotortrends.com"; +const API_VERSION = "v1"; export const SITE_URL: string = process.env.NEXT_PUBLIC_SITE_URL || `https://${DOMAIN_NAME}`; -export const API_URL: string = - process.env.NEXT_PUBLIC_API_URL || `https://api.${DOMAIN_NAME}`; +// Configure the API BASE URL +const DEFAULT_API_URL = `https://api.${DOMAIN_NAME}`; +const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || DEFAULT_API_URL; +export const API_URL: string = `${API_BASE_URL}/${API_VERSION}`; /** * List of make to be excluded from the dataset because they are usually part of the following: diff --git a/utils/fetchApi.ts b/utils/fetchApi.ts index 6ada87a..1b46486 100644 --- a/utils/fetchApi.ts +++ b/utils/fetchApi.ts @@ -6,7 +6,7 @@ export const fetchApi = async ( if (!response.ok) { throw new Error( - `API call failed: ${response.status} - ${response.statusText}`, + `API call failed: ${url} - ${response.status} - ${response.statusText}`, ); }