From 88d77c7754e6bd40f615b213e9d07726972eeda8 Mon Sep 17 00:00:00 2001 From: Alisha Evans Date: Thu, 1 Feb 2024 14:47:20 -0600 Subject: [PATCH 1/2] create the `NEXT_PUBLIC_CLIENT_BASE_URL` env variable this new variable will be necessary so that redirects happen properly when the client is using their own domain, but pointing it to the softserv.cloud instance. - ref: https://github.com/scientist-softserv/phenovista-digital-storefront/issues/46 --- .env | 3 ++- .env.example | 3 ++- README.md | 1 + charts/webstore/templates/deployment.yaml | 2 ++ ops/production-deploy.tmpl.yaml | 1 + ops/staging-deploy.tmpl.yaml | 1 + 6 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.env b/.env index 4a10ac9..22d00ac 100644 --- a/.env +++ b/.env @@ -5,4 +5,5 @@ NEXT_PUBLIC_PROVIDER_NAME=phenovista NEXT_PUBLIC_PROVIDER_ID=12527 NEXT_PUBLIC_SCIENTIST_API_VERSION=v2 NEXT_PUBLIC_WEBHOOK_URL=http://ss-mailer/webstore -NEXT_PUBLIC_APP_BASE_URL=https://www.phenovista.vercel.app +NEXT_PUBLIC_APP_BASE_URL=https://phenovista.softserv.cloud/ +NEXT_PUBLIC_CLIENT_BASE_URL=https://store.phenovista.cloud/ diff --git a/.env.example b/.env.example index 9e0790d..e241547 100644 --- a/.env.example +++ b/.env.example @@ -1,8 +1,9 @@ # reference https://nextjs.org/docs/basic-features/environment-variables#exposing-environment-variables-to-the-browser # to learn about the NEXT_PUBLIC prefix -NEXT_PUBLIC_APP_BASE_URL=https://store.webstore.com +NEXT_PUBLIC_APP_BASE_URL=https://webstore.softserv.com NEXT_PUBLIC_PROVIDER_ID=0001 NEXT_PUBLIC_PROVIDER_NAME=webstore NEXT_PUBLIC_SCIENTIST_API_VERSION=v2 NEXT_PUBLIC_WEBHOOK_URL=http://ss-mailer/webstore +NEXT_PUBLIC_CLIENT_BASE_URL=https://store.webstore.com diff --git a/README.md b/README.md index 7890bf5..fe6a0a5 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ _The terms "client" and "provider" are fairly interchangeable in this applicatio | NEXTAUTH_SECRET | Yes | .env.development | Used to encrypt the NextAuth.js JWT | | NEXTAUTH_URL | Yes | .env.development | The authentication route used for NextAuth.js | | NEXT_PUBLIC_APP_BASE_URL | Yes | .env | The URL to the deployed webstore instance | +| NEXT_PUBLIC_CLIENT_BASE_URL | No | .env | The URL to the Client CNAME that points at NEXT_PUBLIC_APP_BASE_URL | | NEXT_PUBLIC_PROVIDER_ID | Yes | .env | The identifier of the client's marketplace in the database | | NEXT_PUBLIC_PROVIDER_NAME | Yes | .env | The subdomain of the client's marketplace | | NEXT_PUBLIC_SCIENTIST_API_VERSION | Yes | .env | The version of the API we should be talking to | diff --git a/charts/webstore/templates/deployment.yaml b/charts/webstore/templates/deployment.yaml index a624afb..881cfc6 100644 --- a/charts/webstore/templates/deployment.yaml +++ b/charts/webstore/templates/deployment.yaml @@ -44,6 +44,8 @@ spec: value: "{{ .Values.nextAuthUrl }}" - name: NEXT_PUBLIC_APP_BASE_URL value: "{{ .Values.appBaseUrl }}" + - name: NEXT_PUBLIC_CLIENT_BASE_URL + value: "{{ .Values.clientBaseUrl }}" - name: NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID value: "{{ .Values.googleTagManagerId }}" - name: NEXT_PUBLIC_PROVIDER_ID diff --git a/ops/production-deploy.tmpl.yaml b/ops/production-deploy.tmpl.yaml index 1369cf6..b76f9d4 100644 --- a/ops/production-deploy.tmpl.yaml +++ b/ops/production-deploy.tmpl.yaml @@ -1,4 +1,5 @@ appBaseUrl: 'https://phenovista.softserv.cloud' +clientBaseUrl: 'https://store.phenovista.com' clientId: $CLIENT_ID clientSecret: $CLIENT_SECRET googleTagManagerId: 'GTM-PQGCP24G' diff --git a/ops/staging-deploy.tmpl.yaml b/ops/staging-deploy.tmpl.yaml index ebbc985..6090175 100644 --- a/ops/staging-deploy.tmpl.yaml +++ b/ops/staging-deploy.tmpl.yaml @@ -1,4 +1,5 @@ appBaseUrl: 'https://phenovista-staging.softserv.cloud' +clientBaseUrl: '' clientId: $CLIENT_ID clientSecret: $CLIENT_SECRET googleTagManagerId: '' From 10bf88145b0c69fd8a8b619f0e5ed027442e28a6 Mon Sep 17 00:00:00 2001 From: Alisha Evans Date: Thu, 1 Feb 2024 14:51:19 -0600 Subject: [PATCH 2/2] wip: need to test url's in production environment --- pages/api/auth/[...nextauth].js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pages/api/auth/[...nextauth].js b/pages/api/auth/[...nextauth].js index c705fc4..021f71a 100644 --- a/pages/api/auth/[...nextauth].js +++ b/pages/api/auth/[...nextauth].js @@ -29,6 +29,15 @@ const authOptions = { } ], callbacks: { + async redirect({ url, baseUrl }) { + console.log({ + url, baseUrl, client_url: process.env.NEXT_PUBLIC_CLIENT_BASE_URL, + url_Origin: new URL(url).origin, + baseUrl_Origin: new URL(baseUrl).origin, + clientUrl_Origin: new URL(process.env.NEXT_PUBLIC_CLIENT_BASE_URL).origin, + }) + return baseUrl + }, async jwt({ token, account, user }) { // Triggered on the initial sign in if (account && user) {