diff --git a/.env.example b/.env.example index 33a21ae..b651be4 100644 --- a/.env.example +++ b/.env.example @@ -4,3 +4,4 @@ NEXT_PUBLIC_GA_MEASUREMENT_ID= NEXT_PUBLIC_FEATURE_FLAG_RELEASED= NEXT_PUBLIC_REVALIDATE_TOKEN= CLOUDFLARE_API_TOKEN= +SG_CARS_TRENDS_API_TOKEN= diff --git a/.github/workflows/sst.dev.yml b/.github/workflows/sst.dev.yml index c36a1c2..341747e 100644 --- a/.github/workflows/sst.dev.yml +++ b/.github/workflows/sst.dev.yml @@ -45,6 +45,7 @@ jobs: NEXT_PUBLIC_SITE_URL: ${{ vars.NEXT_PUBLIC_SITE_URL }} NEXT_PUBLIC_REVALIDATE_TOKEN: ${{ secrets.NEXT_PUBLIC_REVALIDATE_TOKEN }} CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + SG_CARS_TRENDS_API_TOKEN: ${{ secrets.SG_CARS_TRENDS_API_TOKEN }} steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 diff --git a/.github/workflows/sst.staging.yml b/.github/workflows/sst.staging.yml index d293e30..a2e7e6e 100644 --- a/.github/workflows/sst.staging.yml +++ b/.github/workflows/sst.staging.yml @@ -46,6 +46,7 @@ jobs: NEXT_PUBLIC_SITE_URL: ${{ vars.NEXT_PUBLIC_SITE_URL }} NEXT_PUBLIC_REVALIDATE_TOKEN: ${{ secrets.NEXT_PUBLIC_REVALIDATE_TOKEN }} CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + SG_CARS_TRENDS_API_TOKEN: ${{ secrets.SG_CARS_TRENDS_API_TOKEN }} steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 diff --git a/utils/fetchApi.ts b/utils/fetchApi.ts index 1b46486..917ce5c 100644 --- a/utils/fetchApi.ts +++ b/utils/fetchApi.ts @@ -2,6 +2,12 @@ export const fetchApi = async ( url: string, options: RequestInit = {}, ): Promise => { + options = { + ...options, + headers: { + Authorization: `Bearer ${process.env.SG_CARS_TRENDS_API_TOKEN}`, + }, + }; const response = await fetch(url, options); if (!response.ok) {