From f8cbf8b1c4637ba773af3e5ce03e5c0d503ebdc4 Mon Sep 17 00:00:00 2001 From: Morgan <33722304+ThyMinimalDev@users.noreply.github.com> Date: Tue, 2 Apr 2024 15:23:04 +0300 Subject: [PATCH] chore: rewrite api.cal.com/v2 to api v2 (#14285) * chore: rewrite api.cal.com/v2 to api v2 * fixup! chore: rewrite api.cal.com/v2 to api v2 * fixup! fixup! chore: rewrite api.cal.com/v2 to api v2 --------- Co-authored-by: Alex van Andel --- .../production-build-without-database.yml | 2 ++ .github/workflows/production-build.yml | 2 ++ apps/api/v1/.env.example | 1 + apps/api/v1/next.config.js | 16 ++++++++++++++++ turbo.json | 3 ++- 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/workflows/production-build-without-database.yml b/.github/workflows/production-build-without-database.yml index 40c05b0e92..2542c1c680 100644 --- a/.github/workflows/production-build-without-database.yml +++ b/.github/workflows/production-build-without-database.yml @@ -30,6 +30,8 @@ env: TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} TURBO_TEAM: ${{ secrets.TURBO_TEAM }} NEXT_PUBLIC_API_V2_URL: ${{ secrets.CI_NEXT_PUBLIC_API_V2_URL }} + NEXT_PUBLIC_API_V2_ROOT_URL: ${{ secrets.CI_NEXT_PUBLIC_API_V2_ROOT_URL }} + jobs: build: diff --git a/.github/workflows/production-build.yml b/.github/workflows/production-build.yml index 3f58b9c637..061ebcf8ca 100644 --- a/.github/workflows/production-build.yml +++ b/.github/workflows/production-build.yml @@ -34,6 +34,8 @@ env: TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} TURBO_TEAM: ${{ secrets.TURBO_TEAM }} NEXT_PUBLIC_API_V2_URL: ${{ secrets.CI_NEXT_PUBLIC_API_V2_URL }} + NEXT_PUBLIC_API_V2_ROOT_URL: ${{ secrets.CI_NEXT_PUBLIC_API_V2_ROOT_URL }} + jobs: build: diff --git a/apps/api/v1/.env.example b/apps/api/v1/.env.example index c5354bfd7d..37b43dd557 100644 --- a/apps/api/v1/.env.example +++ b/apps/api/v1/.env.example @@ -4,3 +4,4 @@ NEXT_PUBLIC_WEBAPP_URL=http://localhost:3000 # Get it in console.cal.com CALCOM_LICENSE_KEY="" +NEXT_PUBLIC_API_V2_ROOT_URL=http://localhost:5555 \ No newline at end of file diff --git a/apps/api/v1/next.config.js b/apps/api/v1/next.config.js index 4d861ce3c3..d875b8169c 100644 --- a/apps/api/v1/next.config.js +++ b/apps/api/v1/next.config.js @@ -47,6 +47,22 @@ const nextConfig = { source: "/v:version/:rest*", destination: "/api/v:version/:rest*", }, + { + source: "/api/v2", + destination: `${process.env.NEXT_PUBLIC_API_V2_ROOT_URL}/health`, + }, + { + source: "/api/v2/health", + destination: `${process.env.NEXT_PUBLIC_API_V2_ROOT_URL}/health`, + }, + { + source: "/api/v2/docs/:path*", + destination: `${process.env.NEXT_PUBLIC_API_V2_ROOT_URL}/docs/:path*`, + }, + { + source: "/api/v2/:path*", + destination: `${process.env.NEXT_PUBLIC_API_V2_ROOT_URL}/api/v2/:path*`, + }, // This redirects requests to api/v*/ to /api/ passing version as a query parameter. { source: "/api/v:version/:rest*", diff --git a/turbo.json b/turbo.json index ba7e34058e..bb590849e4 100644 --- a/turbo.json +++ b/turbo.json @@ -399,6 +399,7 @@ "EMBED_PUBLIC_VERCEL_URL", "NEXT_PUBLIC_ENABLE_PROFILE_SWITCHER", "NEXT_PUBLIC_HEAD_SCRIPTS", - "NEXT_PUBLIC_BODY_SCRIPTS" + "NEXT_PUBLIC_BODY_SCRIPTS", + "NEXT_PUBLIC_API_V2_ROOT_URL" ] }