Skip to content

Commit c7ebd1a

Browse files
committed
feat (development): fixing dynamic env loading based on environment (dev, dev-cloud, staging, SELFHOST)
SELFHOST - loads using dotenv in docker container dev - loads using dotenv outside docker container (run via powershell terminals) dev-cloud, staging - load using start.sh script in docker container
1 parent 37729b7 commit c7ebd1a

File tree

31 files changed

+170
-87
lines changed

31 files changed

+170
-87
lines changed

src/client/app/api/chat/message/route.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { NextResponse } from "next/server"
22
import { withAuth } from "@lib/api-utils"
33

44
const appServerUrl =
5-
process.env.INTERNAL_APP_SERVER_URL ||
6-
process.env.NEXT_PUBLIC_APP_SERVER_URL
5+
process.env.NEXT_PUBLIC_ENVIRONMENT === "SELFHOST"
6+
? process.env.INTERNAL_APP_SERVER_URL
7+
: process.env.NEXT_PUBLIC_APP_SERVER_URL
78

89
export const POST = withAuth(async function POST(request, { authHeader }) {
910
try {

src/client/app/api/integrations/connected/route.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import { NextResponse } from "next/server"
33
import { withAuth } from "@lib/api-utils"
44

55
const appServerUrl =
6-
process.env.INTERNAL_APP_SERVER_URL ||
7-
process.env.NEXT_PUBLIC_APP_SERVER_URL
6+
process.env.NEXT_PUBLIC_ENVIRONMENT === "SELFHOST"
7+
? process.env.INTERNAL_APP_SERVER_URL
8+
: process.env.NEXT_PUBLIC_APP_SERVER_URL
89

910
export const GET = withAuth(async function GET(request, { authHeader }) {
1011
try {

src/client/app/api/journal/route.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { NextResponse } from "next/server"
22
import { withAuth } from "@lib/api-utils"
33

44
const APP_SERVER_URL =
5-
process.env.INTERNAL_APP_SERVER_URL ||
6-
process.env.NEXT_PUBLIC_APP_SERVER_URL
5+
process.env.NEXT_PUBLIC_ENVIRONMENT === "SELFHOST"
6+
? process.env.INTERNAL_APP_SERVER_URL
7+
: process.env.NEXT_PUBLIC_APP_SERVER_URL
78

89
// GET: Fetch blocks for a specific date or date range
910
export const GET = withAuth(async function GET(request, { authHeader }) {

src/client/app/api/notifications/delete/route.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { NextResponse } from "next/server"
22
import { withAuth } from "@lib/api-utils"
33

44
const appServerUrl =
5-
process.env.INTERNAL_APP_SERVER_URL ||
6-
process.env.NEXT_PUBLIC_APP_SERVER_URL
5+
process.env.NEXT_PUBLIC_ENVIRONMENT === "SELFHOST"
6+
? process.env.INTERNAL_APP_SERVER_URL
7+
: process.env.NEXT_PUBLIC_APP_SERVER_URL
78

89
export const POST = withAuth(async function POST(request, { authHeader }) {
910
try {

src/client/app/api/notifications/route.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import { NextResponse } from "next/server"
33
import { withAuth } from "@lib/api-utils"
44

5-
const appServerUrl =
6-
process.env.INTERNAL_APP_SERVER_URL ||
7-
process.env.NEXT_PUBLIC_APP_SERVER_URL
5+
const appServerUrl = process.env.NEXT_PUBLIC_ENVIRONMENT === 'SELFHOST'
6+
? process.env.INTERNAL_APP_SERVER_URL
7+
: process.env.NEXT_PUBLIC_APP_SERVER_URL;
88

99
export const GET = withAuth(async function GET(request, { authHeader }) {
1010
try {

src/client/app/api/onboarding/route.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { NextResponse } from "next/server"
22
import { withAuth } from "@lib/api-utils"
33

44
const appServerUrl =
5-
process.env.INTERNAL_APP_SERVER_URL ||
6-
process.env.NEXT_PUBLIC_APP_SERVER_URL
5+
process.env.NEXT_PUBLIC_ENVIRONMENT === "SELFHOST"
6+
? process.env.INTERNAL_APP_SERVER_URL
7+
: process.env.NEXT_PUBLIC_APP_SERVER_URL
78

89
export const POST = withAuth(async function POST(request, { authHeader }) {
910
try {

src/client/app/api/settings/google-auth/route.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { NextResponse } from "next/server"
22
import { withAuth } from "@lib/api-utils"
33

44
const appServerUrl =
5-
process.env.INTERNAL_APP_SERVER_URL ||
6-
process.env.NEXT_PUBLIC_APP_SERVER_URL
5+
process.env.NEXT_PUBLIC_ENVIRONMENT === "SELFHOST"
6+
? process.env.INTERNAL_APP_SERVER_URL
7+
: process.env.NEXT_PUBLIC_APP_SERVER_URL
78

89
export const GET = withAuth(async function GET(request, { authHeader }) {
910
try {

src/client/app/api/settings/integrations/connect/manual/route.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { NextResponse } from "next/server"
22
import { withAuth } from "@lib/api-utils"
33

44
const appServerUrl =
5-
process.env.INTERNAL_APP_SERVER_URL ||
6-
process.env.NEXT_PUBLIC_APP_SERVER_URL
5+
process.env.NEXT_PUBLIC_ENVIRONMENT === "SELFHOST"
6+
? process.env.INTERNAL_APP_SERVER_URL
7+
: process.env.NEXT_PUBLIC_APP_SERVER_URL
78

89
export const POST = withAuth(async function POST(request, { authHeader }) {
910
try {

src/client/app/api/settings/integrations/connect/oauth/route.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import { NextResponse } from "next/server"
33
import { withAuth } from "@lib/api-utils"
44

55
const appServerUrl =
6-
process.env.INTERNAL_APP_SERVER_URL ||
7-
process.env.NEXT_PUBLIC_APP_SERVER_URL
6+
process.env.NEXT_PUBLIC_ENVIRONMENT === "SELFHOST"
7+
? process.env.INTERNAL_APP_SERVER_URL
8+
: process.env.NEXT_PUBLIC_APP_SERVER_URL
89

910
export const POST = withAuth(async function POST(request, { authHeader }) {
1011
try {

src/client/app/api/settings/integrations/disconnect/route.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { NextResponse } from "next/server"
22
import { withAuth } from "@lib/api-utils"
33

44
const appServerUrl =
5-
process.env.INTERNAL_APP_SERVER_URL ||
6-
process.env.NEXT_PUBLIC_APP_SERVER_URL
5+
process.env.NEXT_PUBLIC_ENVIRONMENT === "SELFHOST"
6+
? process.env.INTERNAL_APP_SERVER_URL
7+
: process.env.NEXT_PUBLIC_APP_SERVER_URL
78

89
export const POST = withAuth(async function POST(request, { authHeader }) {
910
try {

0 commit comments

Comments
 (0)