Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

make getProPlanId work with vite

Brendan Alland8bd14e624c0
diff --git a/.env.example b/.env.example
index c2253bfe8..8fdb5fe45 100644
--- a/.env.example
+++ b/.env.example
@@ -18,10 +18,12 @@
NEXT_PUBLIC_ENVIRONMENT=development
NEXT_PUBLIC_URL=http://localhost:3000
NEXT_PUBLIC_PORT=3000
+NEXT_PUBLIC_TASKS_URL=http://localhost:3002
+
NEXT_PUBLIC_URL=http://localhost:${NEXT_PUBLIC_PORT}
NEXTAUTH_URL=${NEXT_PUBLIC_URL}
VITE_SERVER_URL=${NEXT_PUBLIC_URL}
-NEXT_PUBLIC_TASKS_URL=http://localhost:3002
+VITE_ENVIRONMENT=${NEXT_PUBLIC_ENVIRONMENT}
# IMPORTANT FOR LOCAL DEV:
# This determines whether or not the app will run in "local mode".
diff --git a/packages/utils/src/constants/plans.ts b/packages/utils/src/constants/plans.ts
index f752f47c8..9f0a4eee1 100644
--- a/packages/utils/src/constants/plans.ts
+++ b/packages/utils/src/constants/plans.ts
@@ -10,10 +10,9 @@ const planIds = {
};
export const getProPlanId = (billingCycle: "yearly" | "monthly") => {
- const environment =
- process.env.NEXT_PUBLIC_ENVIRONMENT === "development"
- ? "development"
- : "production";
+ const value =
+ import.meta.env.VITE_ENVIRONMENT ?? process.env.NEXT_PUBLIC_ENVIRONMENT;
+ const environment = value === "development" ? "development" : "production";
return planIds[environment]?.[billingCycle] || "";
};
@@ -30,7 +29,7 @@ export const isUserOnProPlan = ({
subscriptionStatus === "paid"
) {
return true;
- } else {
- return false;
}
+
+ return false;
};