mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-22 21:28:12 +02:00
refactor(web): update environment variable handling to use build-time constants for auth type, deployment mode, and ETL service
This commit is contained in:
parent
3f69bfd5e4
commit
695da76f2e
3 changed files with 15 additions and 11 deletions
2
.github/workflows/desktop-release.yml
vendored
2
.github/workflows/desktop-release.yml
vendored
|
|
@ -99,7 +99,7 @@ jobs:
|
||||||
SURFSENSE_BACKEND_INTERNAL_URL: ${{ vars.NEXT_PUBLIC_FASTAPI_BACKEND_URL }}
|
SURFSENSE_BACKEND_INTERNAL_URL: ${{ vars.NEXT_PUBLIC_FASTAPI_BACKEND_URL }}
|
||||||
NEXT_PUBLIC_ZERO_CACHE_URL: ${{ vars.NEXT_PUBLIC_ZERO_CACHE_URL }}
|
NEXT_PUBLIC_ZERO_CACHE_URL: ${{ vars.NEXT_PUBLIC_ZERO_CACHE_URL }}
|
||||||
NEXT_PUBLIC_DEPLOYMENT_MODE: ${{ vars.NEXT_PUBLIC_DEPLOYMENT_MODE }}
|
NEXT_PUBLIC_DEPLOYMENT_MODE: ${{ vars.NEXT_PUBLIC_DEPLOYMENT_MODE }}
|
||||||
NEXT_PUBLIC_FASTAPI_BACKEND_AUTH_TYPE: ${{ vars.NEXT_PUBLIC_FASTAPI_BACKEND_AUTH_TYPE }}
|
NEXT_PUBLIC_AUTH_TYPE: ${{ vars.NEXT_PUBLIC_AUTH_TYPE }}
|
||||||
NEXT_PUBLIC_ETL_SERVICE: ${{ vars.NEXT_PUBLIC_ETL_SERVICE }}
|
NEXT_PUBLIC_ETL_SERVICE: ${{ vars.NEXT_PUBLIC_ETL_SERVICE }}
|
||||||
NEXT_PUBLIC_POSTHOG_KEY: ${{ secrets.NEXT_PUBLIC_POSTHOG_KEY }}
|
NEXT_PUBLIC_POSTHOG_KEY: ${{ secrets.NEXT_PUBLIC_POSTHOG_KEY }}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,18 @@
|
||||||
import { connection } from "next/server";
|
import { connection } from "next/server";
|
||||||
import { RuntimeConfigProvider } from "@/components/providers/runtime-config";
|
import { RuntimeConfigProvider } from "@/components/providers/runtime-config";
|
||||||
import { AUTH_TYPE, DEPLOYMENT_MODE, ETL_SERVICE } from "@/lib/env-config";
|
import {
|
||||||
|
BUILD_TIME_AUTH_TYPE,
|
||||||
|
BUILD_TIME_DEPLOYMENT_MODE,
|
||||||
|
BUILD_TIME_ETL_SERVICE,
|
||||||
|
} from "@/lib/env-config";
|
||||||
|
|
||||||
export async function RuntimeConfig({ children }: { children: React.ReactNode }) {
|
export async function RuntimeConfig({ children }: { children: React.ReactNode }) {
|
||||||
await connection();
|
await connection();
|
||||||
|
|
||||||
const value = {
|
const value = {
|
||||||
authType: process.env.AUTH_TYPE ?? AUTH_TYPE,
|
authType: process.env.AUTH_TYPE ?? BUILD_TIME_AUTH_TYPE,
|
||||||
etlService: process.env.ETL_SERVICE ?? ETL_SERVICE,
|
etlService: process.env.ETL_SERVICE ?? BUILD_TIME_ETL_SERVICE,
|
||||||
deploymentMode: process.env.DEPLOYMENT_MODE ?? DEPLOYMENT_MODE,
|
deploymentMode: process.env.DEPLOYMENT_MODE ?? BUILD_TIME_DEPLOYMENT_MODE,
|
||||||
};
|
};
|
||||||
|
|
||||||
return <RuntimeConfigProvider value={value}>{children}</RuntimeConfigProvider>;
|
return <RuntimeConfigProvider value={value}>{children}</RuntimeConfigProvider>;
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@
|
||||||
import packageJson from "../package.json";
|
import packageJson from "../package.json";
|
||||||
|
|
||||||
// Build-time fallback for packaged clients. Docker runtime reads plain AUTH_TYPE
|
// Build-time fallback for packaged clients. Docker runtime reads plain AUTH_TYPE
|
||||||
// through the runtime config provider instead.
|
// through the runtime config provider first, then falls back to this baked value.
|
||||||
export const AUTH_TYPE = process.env.NEXT_PUBLIC_FASTAPI_BACKEND_AUTH_TYPE || "GOOGLE";
|
export const BUILD_TIME_AUTH_TYPE = process.env.NEXT_PUBLIC_AUTH_TYPE || "GOOGLE";
|
||||||
|
|
||||||
// Backend API URL. An empty string is valid in proxy mode and means
|
// Backend API URL. An empty string is valid in proxy mode and means
|
||||||
// same-origin relative requests (e.g. /api/v1/... and /auth/...).
|
// same-origin relative requests (e.g. /api/v1/... and /auth/...).
|
||||||
|
|
@ -63,12 +63,12 @@ export const SERVER_BACKEND_URL =
|
||||||
"http://backend:8000";
|
"http://backend:8000";
|
||||||
|
|
||||||
// Build-time fallback for packaged clients. Docker runtime reads plain ETL_SERVICE
|
// Build-time fallback for packaged clients. Docker runtime reads plain ETL_SERVICE
|
||||||
// through the runtime config provider instead.
|
// through the runtime config provider first, then falls back to this baked value.
|
||||||
export const ETL_SERVICE = process.env.NEXT_PUBLIC_ETL_SERVICE || "DOCLING";
|
export const BUILD_TIME_ETL_SERVICE = process.env.NEXT_PUBLIC_ETL_SERVICE || "DOCLING";
|
||||||
|
|
||||||
// Build-time fallback for packaged clients. Docker runtime reads plain
|
// Build-time fallback for packaged clients. Docker runtime reads plain
|
||||||
// DEPLOYMENT_MODE through the runtime config provider instead.
|
// DEPLOYMENT_MODE through the runtime config provider first, then falls back to this baked value.
|
||||||
export const DEPLOYMENT_MODE = process.env.NEXT_PUBLIC_DEPLOYMENT_MODE || "self-hosted";
|
export const BUILD_TIME_DEPLOYMENT_MODE = process.env.NEXT_PUBLIC_DEPLOYMENT_MODE || "self-hosted";
|
||||||
|
|
||||||
// App version - defaults to package.json version
|
// App version - defaults to package.json version
|
||||||
// Can be overridden at build time with NEXT_PUBLIC_APP_VERSION for full git tag version
|
// Can be overridden at build time with NEXT_PUBLIC_APP_VERSION for full git tag version
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue