From ce1d8e8dd5691319247d6dba60066c9469378f74 Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal Date: Wed, 24 Jul 2024 16:44:54 +0530 Subject: [PATCH] chore: runtime env --- web/app/env-setup.tsx | 12 ++++++++++++ web/app/layout.tsx | 6 +++++- web/next.config.js | 9 ++++----- 3 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 web/app/env-setup.tsx diff --git a/web/app/env-setup.tsx b/web/app/env-setup.tsx new file mode 100644 index 0000000000..76613fc784 --- /dev/null +++ b/web/app/env-setup.tsx @@ -0,0 +1,12 @@ +"use server"; + +import { unstable_noStore as noStore } from "next/cache"; + +export default async function getEnvVariables() { + noStore(); + + return { + plausible: process.env.PLAUSIBLE_DOMAIN, + adminBase: process.env.NEXT_PUBLIC_ADMIN_BASE_URL, + }; +} diff --git a/web/app/layout.tsx b/web/app/layout.tsx index e1690a17c5..decdcbf13f 100644 --- a/web/app/layout.tsx +++ b/web/app/layout.tsx @@ -8,6 +8,7 @@ import "@/styles/react-day-picker.css"; // helpers import { API_BASE_URL } from "@/helpers/common.helper"; // local +import getEnvVariables from "./env-setup"; import { AppProvider } from "./provider"; export const metadata: Metadata = { @@ -27,9 +28,12 @@ export const metadata: Metadata = { }, }; -export default function RootLayout({ children }: { children: React.ReactNode }) { +export default async function RootLayout({ children }: { children: React.ReactNode }) { const isSessionRecorderEnabled = parseInt(process.env.NEXT_PUBLIC_ENABLE_SESSION_RECORDER || "0"); + const envVars = await getEnvVariables(); + console.log("envVars", envVars); + return ( diff --git a/web/next.config.js b/web/next.config.js index ad2914df0d..c91804eafa 100644 --- a/web/next.config.js +++ b/web/next.config.js @@ -7,7 +7,7 @@ const nextConfig = { trailingSlash: true, reactStrictMode: false, swcMinify: true, - output: "standalone", + // output: "standalone", async headers() { return [ { @@ -56,7 +56,7 @@ const nextConfig = { ]; }, async rewrites() { - const posthogHost = process.env.NEXT_PUBLIC_POSTHOG_HOST || "https://app.posthog.com" + const posthogHost = process.env.NEXT_PUBLIC_POSTHOG_HOST || "https://app.posthog.com"; const rewrites = [ { source: "/ingest/static/:path*", @@ -74,7 +74,7 @@ const nextConfig = { rewrites.push({ source: "/god-mode", destination: `${GOD_MODE_BASE_URL}/`, - }) + }); rewrites.push({ source: "/god-mode/:path*", destination: `${GOD_MODE_BASE_URL}/:path*`, @@ -113,8 +113,7 @@ const sentryConfig = { // https://docs.sentry.io/product/crons/ // https://vercel.com/docs/cron-jobs automaticVercelMonitors: true, -} - +}; if (parseInt(process.env.SENTRY_MONITORING_ENABLED || "0", 10)) { module.exports = withSentryConfig(nextConfig, sentryConfig);