Skip to content

Commit

Permalink
Merge pull request #73 from ruchernchong/72-update-api-to-reflect-ver…
Browse files Browse the repository at this point in the history
…sioning

Update API to use versioning
  • Loading branch information
ruchernchong authored Aug 2, 2024
2 parents 41d5f81 + f654a37 commit 82a52f3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/sst.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
9 changes: 6 additions & 3 deletions config/index.ts
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion utils/fetchApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const fetchApi = async <T>(

if (!response.ok) {
throw new Error(
`API call failed: ${response.status} - ${response.statusText}`,
`API call failed: ${url} - ${response.status} - ${response.statusText}`,
);
}

Expand Down

0 comments on commit 82a52f3

Please sign in to comment.