diff --git a/apps/web/src/pages/api/stripe/create_billing_session.ts b/apps/web/src/pages/api/stripe/create_billing_session.ts
index 3aa52690..3738703b 100644
--- a/apps/web/src/pages/api/stripe/create_billing_session.ts
+++ b/apps/web/src/pages/api/stripe/create_billing_session.ts
@@ -1,4 +1,5 @@
import type { NextApiRequest, NextApiResponse } from "next";
+import { env } from "next-runtime-env";
import { createNextApiContext } from "@kan/api/trpc";
import { createStripeClient } from "@kan/stripe";
@@ -22,7 +23,7 @@ export default async function handler(
const session = await stripe.billingPortal.sessions.create({
customer: user.stripeCustomerId,
- return_url: `${process.env.NEXT_PUBLIC_BASE_URL}/settings`,
+ return_url: `${env("NEXT_PUBLIC_BASE_URL")}/settings`,
});
return res.status(200).json({ url: session.url });
diff --git a/apps/web/src/pages/api/stripe/create_checkout_session.ts b/apps/web/src/pages/api/stripe/create_checkout_session.ts
index 9dacef99..d4c7c0cd 100644
--- a/apps/web/src/pages/api/stripe/create_checkout_session.ts
+++ b/apps/web/src/pages/api/stripe/create_checkout_session.ts
@@ -1,4 +1,5 @@
import type { NextApiRequest, NextApiResponse } from "next";
+import { env } from "next-runtime-env";
import { z } from "zod";
import { createNextApiContext } from "@kan/api/trpc";
@@ -73,8 +74,8 @@ export default async function handler(
quantity: 1,
},
],
- success_url: `${process.env.NEXT_PUBLIC_BASE_URL}${successUrl}`,
- cancel_url: `${process.env.NEXT_PUBLIC_BASE_URL}${cancelUrl}`,
+ success_url: `${env("NEXT_PUBLIC_BASE_URL")}${successUrl}`,
+ cancel_url: `${env("NEXT_PUBLIC_BASE_URL")}${cancelUrl}`,
customer: user.stripeCustomerId ?? undefined,
metadata: {
workspaceSlug: slug,
diff --git a/apps/web/src/pages/api/upload/image.ts b/apps/web/src/pages/api/upload/image.ts
index 703d19a6..b824cc5d 100644
--- a/apps/web/src/pages/api/upload/image.ts
+++ b/apps/web/src/pages/api/upload/image.ts
@@ -1,8 +1,7 @@
import type { NextApiRequest, NextApiResponse } from "next";
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
-
-import { env } from "~/env";
+import { env } from "next-runtime-env";
export default async function handler(
req: NextApiRequest,
@@ -28,7 +27,7 @@ export default async function handler(
// @ts-ignore
client,
new PutObjectCommand({
- Bucket: process.env.NEXT_PUBLIC_AVATAR_BUCKET_NAME ?? "",
+ Bucket: env("NEXT_PUBLIC_AVATAR_BUCKET_NAME") ?? "",
Key: filename,
}),
);
diff --git a/apps/web/src/utils/helpers.ts b/apps/web/src/utils/helpers.ts
index dd4900a1..672ac162 100644
--- a/apps/web/src/utils/helpers.ts
+++ b/apps/web/src/utils/helpers.ts
@@ -1,4 +1,4 @@
-import { env } from "~/env";
+import { env } from "next-runtime-env";
export const formatToArray = (
value: string | string[] | undefined,
@@ -46,5 +46,5 @@ export const formatMemberDisplayName = (
};
export const getAvatarUrl = (key: string) => {
- return `${env.NEXT_PUBLIC_STORAGE_URL}/${env.NEXT_PUBLIC_AVATAR_BUCKET_NAME}/${key}`;
+ return `${env("NEXT_PUBLIC_STORAGE_URL")}/${env("NEXT_PUBLIC_AVATAR_BUCKET_NAME")}/${key}`;
};
diff --git a/apps/web/src/views/settings/components/Avatar.tsx b/apps/web/src/views/settings/components/Avatar.tsx
index 30666f9d..0d30e458 100644
--- a/apps/web/src/views/settings/components/Avatar.tsx
+++ b/apps/web/src/views/settings/components/Avatar.tsx
@@ -1,7 +1,7 @@
import Image from "next/image";
+import { env } from "next-runtime-env";
import { useState } from "react";
-import { env } from "~/env";
import { usePopup } from "~/providers/popup";
import { api } from "~/utils/api";
import { getAvatarUrl } from "~/utils/helpers";
@@ -62,7 +62,7 @@ export default function Avatar({
setUploading(true);
const response = await fetch(
- env.NEXT_PUBLIC_BASE_URL + "/api/upload/image",
+ env("NEXT_PUBLIC_BASE_URL") + "/api/upload/image",
{
method: "POST",
headers: {
diff --git a/apps/web/src/views/settings/index.tsx b/apps/web/src/views/settings/index.tsx
index 25b1575f..9d04608b 100644
--- a/apps/web/src/views/settings/index.tsx
+++ b/apps/web/src/views/settings/index.tsx
@@ -1,3 +1,4 @@
+import { env } from "next-runtime-env";
import { HiMiniArrowTopRightOnSquare } from "react-icons/hi2";
import Button from "~/components/Button";
@@ -95,7 +96,7 @@ export default function SettingsPage() {
/>
- {process.env.NEXT_PUBLIC_KAN_ENV === "cloud" && (
+ {env("NEXT_PUBLIC_KAN_ENV") === "cloud" && (
Billing
diff --git a/docker-compose.yml b/docker-compose.yml
index 7b0c627e..c0634cfb 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -2,6 +2,7 @@ version: "3.7"
services:
web:
+ image: ghcr.io/kanbn/kan:latest
ports:
- "3001:3000"
networks:
@@ -9,12 +10,6 @@ services:
build:
context: .
dockerfile: ./apps/web/Dockerfile
- args:
- NEXT_PUBLIC_KAN_ENV: ${NEXT_PUBLIC_KAN_ENV}
- NEXT_PUBLIC_UMAMI_ID: ${NEXT_PUBLIC_UMAMI_ID}
- NEXT_PUBLIC_BASE_URL: ${NEXT_PUBLIC_BASE_URL}
- NEXT_PUBLIC_STORAGE_URL: ${NEXT_PUBLIC_STORAGE_URL}
- NEXT_PUBLIC_AVATAR_BUCKET_NAME: ${NEXT_PUBLIC_AVATAR_BUCKET_NAME}
env_file:
- .env
command: ["pnpm", "start"]
@@ -40,7 +35,6 @@ services:
- NEXT_PUBLIC_AVATAR_BUCKET_NAME=${NEXT_PUBLIC_AVATAR_BUCKET_NAME}
- NEXT_PUBLIC_STORAGE_DOMAIN=${NEXT_PUBLIC_STORAGE_DOMAIN}
- NEXT_PUBLIC_UMAMI_ID=${NEXT_PUBLIC_UMAMI_ID}
-
networks:
dokploy-network:
external: true
diff --git a/packages/api/src/openapi.ts b/packages/api/src/openapi.ts
index 48203534..9a7ad7b4 100644
--- a/packages/api/src/openapi.ts
+++ b/packages/api/src/openapi.ts
@@ -1,3 +1,4 @@
+import { env } from "next-runtime-env";
import { generateOpenApiDocument } from "trpc-to-openapi";
import { appRouter } from "./root";
@@ -6,7 +7,7 @@ export const openApiDocument = generateOpenApiDocument(appRouter, {
title: "Kan API",
description: "OpenAPI compliant REST API",
version: "1.0.0",
- baseUrl: `${process.env.NEXT_PUBLIC_BASE_URL}/api/v1`,
+ baseUrl: `${env("NEXT_PUBLIC_BASE_URL")}/api/v1`,
docsUrl: "docs.kan.bn",
tags: ["Auth", "Users", "Boards", "Lists", "Cards", "Labels", "Imports"],
});
diff --git a/packages/auth/src/auth.ts b/packages/auth/src/auth.ts
index 53ee7bbf..fc705471 100644
--- a/packages/auth/src/auth.ts
+++ b/packages/auth/src/auth.ts
@@ -3,6 +3,7 @@ import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { createAuthMiddleware } from "better-auth/api";
import { apiKey } from "better-auth/plugins";
import { magicLink } from "better-auth/plugins/magic-link";
+import { env } from "next-runtime-env";
import type { dbClient } from "@kan/db/client";
import * as memberRepo from "@kan/db/repository/member.repo";
@@ -70,7 +71,7 @@ export const initAuth = (db: dbClient) => {
const user = ctx.context.session?.user;
if (
- process.env.NEXT_PUBLIC_KAN_ENV === "cloud" &&
+ env("NEXT_PUBLIC_KAN_ENV") === "cloud" &&
user &&
!user.stripeCustomerId
) {
diff --git a/packages/email/src/templates/join-workspace.tsx b/packages/email/src/templates/join-workspace.tsx
index 0e13b47a..644fe8fb 100644
--- a/packages/email/src/templates/join-workspace.tsx
+++ b/packages/email/src/templates/join-workspace.tsx
@@ -8,6 +8,7 @@ import { Html } from "@react-email/html";
import { Link } from "@react-email/link";
import { Preview } from "@react-email/preview";
import { Text } from "@react-email/text";
+import { env } from "next-runtime-env";
import * as React from "react";
export const JoinWorkspaceTemplate = ({
@@ -90,7 +91,7 @@ export const JoinWorkspaceTemplate = ({
/>
diff --git a/packages/email/src/templates/magic-link.tsx b/packages/email/src/templates/magic-link.tsx
index 90059a76..cf689c70 100644
--- a/packages/email/src/templates/magic-link.tsx
+++ b/packages/email/src/templates/magic-link.tsx
@@ -8,6 +8,7 @@ import { Html } from "@react-email/html";
import { Link } from "@react-email/link";
import { Preview } from "@react-email/preview";
import { Text } from "@react-email/text";
+import { env } from "next-runtime-env";
import * as React from "react";
export const MagicLinkTemplate = ({
@@ -90,7 +91,7 @@ export const MagicLinkTemplate = ({
/>
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 4863cf1e..094e9f7d 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -138,6 +138,9 @@ importers:
next-logger:
specifier: ^5.0.1
version: 5.0.1(next@14.2.20(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(pino@9.6.0)
+ next-runtime-env:
+ specifier: ^1.7.2
+ version: 1.8.0
nextjs-cors:
specifier: ^2.2.0
version: 2.2.0(next@14.2.20(react-dom@18.3.1(react@18.3.1))(react@18.3.1))
@@ -4461,6 +4464,9 @@ packages:
winston:
optional: true
+ next-runtime-env@1.8.0:
+ resolution: {integrity: sha512-QJVxzmr2gTao/vZKFgcrByFrifl0YOMTvuUVxcI/X7ratlW+9zMvMmA9AGU9cFsumXJtohWkCvwPdBNdkTCYfw==}
+
next@14.2.20:
resolution: {integrity: sha512-yPvIiWsiyVYqJlSQxwmzMIReXn5HxFNq4+tlVQ812N1FbvhmE+fDpIAD7bcS2mGYQwPJ5vAsQouyme2eKsxaug==}
engines: {node: '>=18.17.0'}
@@ -10665,6 +10671,10 @@ snapshots:
optionalDependencies:
pino: 9.6.0
+ next-runtime-env@1.8.0:
+ dependencies:
+ chalk: 4.1.2
+
next@14.2.20(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
dependencies:
'@next/env': 14.2.20