From 119600b64f48d8cc6bf39bd28385a05e6e92e651 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Mon, 20 Mar 2023 10:19:09 -0700 Subject: [PATCH] remove site url env var from frontend --- frontend/src/components/utilities/config/index.ts | 2 -- frontend/src/components/utilities/generateBackupPDF.ts | 10 ++++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/utilities/config/index.ts b/frontend/src/components/utilities/config/index.ts index 5a55658e4..7570785ba 100644 --- a/frontend/src/components/utilities/config/index.ts +++ b/frontend/src/components/utilities/config/index.ts @@ -4,13 +4,11 @@ const POSTHOG_HOST = process.env.NEXT_PUBLIC_POSTHOG_HOST! || "https://app.posthog.com"; const STRIPE_PRODUCT_PRO = process.env.NEXT_PUBLIC_STRIPE_PRODUCT_PRO!; const STRIPE_PRODUCT_STARTER = process.env.NEXT_PUBLIC_STRIPE_PRODUCT_STARTER!; -const SITE_URL = "https://app.infisical.com"; export { ENV, POSTHOG_API_KEY, POSTHOG_HOST, - SITE_URL, STRIPE_PRODUCT_PRO, STRIPE_PRODUCT_STARTER }; \ No newline at end of file diff --git a/frontend/src/components/utilities/generateBackupPDF.ts b/frontend/src/components/utilities/generateBackupPDF.ts index 3e2246db6..41fb49f13 100644 --- a/frontend/src/components/utilities/generateBackupPDF.ts +++ b/frontend/src/components/utilities/generateBackupPDF.ts @@ -1,7 +1,5 @@ import { jsPDF } from 'jspdf'; -import { SITE_URL } from './config'; - interface PDFProps { personalName: string; personalEmail: string; @@ -19,7 +17,7 @@ const yyyy = today.getFullYear(); const todayFormatted = `${mm}/${dd}/${yyyy}`; -function createPdfHeader(doc: jsPDF, personalName : string) { +function createPdfHeader(doc: jsPDF, personalName: string) { doc.setFillColor(255, 255, 255); doc.rect(0, 0, 600, 900, 'F'); doc.setTextColor(23, 23, 23); @@ -30,6 +28,10 @@ function createPdfHeader(doc: jsPDF, personalName : string) { } function createPdfContent(doc: jsPDF, personalEmail: string, generatedKey: string) { + const { protocol, hostname, port } = window.location; + const portSuffix = port && port !== '80' ? `:${port}` : ''; + const siteURL = `${protocol}//${hostname}${portSuffix}`; + doc.setFontSize(14); doc.text( 'In case you get locked out of you Infisical account, you`ll need these account details', @@ -73,7 +75,7 @@ function createPdfContent(doc: jsPDF, personalEmail: string, generatedKey: strin doc.roundedRect(170, 488, 375, 35, 5, 5, 'F'); doc.setTextColor(23, 23, 23); doc.setFontSize(14); - doc.text(`${SITE_URL}/login`, 180, 420); + doc.text(`${siteURL}/login`, 180, 420); doc.text(personalEmail, 180, 465); doc.text(generatedKey, 180, 510); doc.text('Need help? Contact us at support@infisical.com', 32, 575);