Moved env checks to server pages.

This commit is contained in:
Mike Cao 2025-07-24 23:05:51 -07:00
parent 5b6292dd11
commit 784677e180
7 changed files with 18 additions and 18 deletions

View file

@ -22,10 +22,6 @@ export function App({ children }) {
return null;
}
if (config.uiDisabled) {
return null;
}
return (
<>
{children}

View file

@ -2,22 +2,18 @@
export type Config = {
faviconUrl: string | undefined;
loginDisabled: boolean;
privateMode: boolean;
telemetryDisabled: boolean;
trackerScriptName: string | undefined;
uiDisabled: boolean;
updatesDisabled: boolean;
};
export async function getConfig(): Promise<Config> {
return {
faviconUrl: process.env.FAVICON_URL,
loginDisabled: !!process.env.DISABLE_LOGIN,
privateMode: !!process.env.PRIVATE_MODE,
telemetryDisabled: !!process.env.DISABLE_TELEMETRY,
trackerScriptName: process.env.TRACKER_SCRIPT_NAME,
uiDisabled: !!process.env.DISABLE_UI,
updatesDisabled: !!process.env.DISABLE_UPDATES,
};
}

View file

@ -9,6 +9,14 @@ import '@/styles/index.css';
import '@/styles/variables.css';
export default function ({ children }) {
if (process.env.DISABLE_UI) {
return (
<html>
<body></body>
</html>
);
}
return (
<html lang="en" data-scroll="0">
<head>

View file

@ -1,15 +1,8 @@
'use client';
import { useConfig } from '@/components/hooks';
import LoginForm from './LoginForm';
import styles from './LoginPage.module.css';
export function LoginPage() {
const config = useConfig();
if (config?.loginDisabled) {
return null;
}
return (
<div className={styles.page}>
<LoginForm />

View file

@ -2,6 +2,10 @@ import { Metadata } from 'next';
import LoginPage from './LoginPage';
export default async function () {
if (process.env.DISABLE_LOGIN) {
return null;
}
return <LoginPage />;
}

View file

@ -1,15 +1,14 @@
'use client';
import { useEffect } from 'react';
import { useRouter } from 'next/navigation';
import { useApi, useConfig } from '@/components/hooks';
import { useApi } from '@/components/hooks';
import { setUser } from '@/store/app';
import { removeClientAuthToken } from '@/lib/client';
export function LogoutPage() {
const config = useConfig();
const router = useRouter();
const { post } = useApi();
const disabled = !!(config?.loginDisabled || process.env.cloudMode);
const disabled = process.env.cloudMode;
useEffect(() => {
async function logout() {

View file

@ -2,6 +2,10 @@ import LogoutPage from './LogoutPage';
import { Metadata } from 'next';
export default function () {
if (process.env.DISABLE_LOGIN) {
return null;
}
return <LogoutPage />;
}