diff --git a/apps/readest-app/.env.local.example b/apps/readest-app/.env.local.example index f3ccf16a..e009a3c7 100644 --- a/apps/readest-app/.env.local.example +++ b/apps/readest-app/.env.local.example @@ -6,6 +6,8 @@ NEXT_PUBLIC_SUPABASE_ANON_KEY=YOUR_SUPABASE_ANON_KEY NEXT_PUBLIC_STORAGE_FIXED_QUOTA=1073741824 +NEXT_PUBLIC_API_BASE_URL=https://your-api-base-url.com + SUPABASE_ADMIN_KEY=YOUR_SUPABASE_ADMIN_KEY DEEPL_PRO_API_KEYS=YOUR_DEEPL_PRO_API_KEYS diff --git a/apps/readest-app/src/app/auth/page.tsx b/apps/readest-app/src/app/auth/page.tsx index 3f8f030a..4906076e 100644 --- a/apps/readest-app/src/app/auth/page.tsx +++ b/apps/readest-app/src/app/auth/page.tsx @@ -18,14 +18,13 @@ import { useThemeStore } from '@/store/themeStore'; import { useSettingsStore } from '@/store/settingsStore'; import { useTranslation } from '@/hooks/useTranslation'; import { useTrafficLightStore } from '@/store/trafficLightStore'; -import { isTauriAppPlatform } from '@/services/environment'; +import { getBaseUrl, isTauriAppPlatform } from '@/services/environment'; import { onOpenUrl } from '@tauri-apps/plugin-deep-link'; import { start, cancel, onUrl, onInvalidUrl } from '@fabianlars/tauri-plugin-oauth'; import { openUrl } from '@tauri-apps/plugin-opener'; import { handleAuthCallback } from '@/helpers/auth'; import { getAppleIdAuth, Scope } from './utils/appleIdAuth'; import { authWithCustomTab, authWithSafari } from './utils/nativeAuth'; -import { READEST_WEB_BASE_URL } from '@/services/constants'; import WindowButtons from '@/components/WindowButtons'; type OAuthProvider = 'google' | 'apple' | 'azure' | 'github'; @@ -42,7 +41,7 @@ interface ProviderLoginProp { label: string; } -const WEB_AUTH_CALLBACK = `${READEST_WEB_BASE_URL}/auth/callback`; +const WEB_AUTH_CALLBACK = `${getBaseUrl()}/auth/callback`; const DEEPLINK_CALLBACK = 'readest://auth-callback'; const USE_APPLE_SIGN_IN = process.env['NEXT_PUBLIC_USE_APPLE_SIGN_IN'] === 'true'; diff --git a/apps/readest-app/src/services/environment.ts b/apps/readest-app/src/services/environment.ts index cf849308..beed8644 100644 --- a/apps/readest-app/src/services/environment.ts +++ b/apps/readest-app/src/services/environment.ts @@ -11,14 +11,13 @@ export const isTauriAppPlatform = () => process.env['NEXT_PUBLIC_APP_PLATFORM'] export const isWebAppPlatform = () => process.env['NEXT_PUBLIC_APP_PLATFORM'] === 'web'; export const hasCli = () => window.__READEST_CLI_ACCESS === true; export const isPWA = () => window.matchMedia('(display-mode: standalone)').matches; +export const getBaseUrl = () => process.env['NEXT_PUBLIC_API_BASE_URL'] ?? READEST_WEB_BASE_URL; // Dev API only in development mode and web platform // with command `pnpm dev-web` // for production build or tauri app use the production Web API export const getAPIBaseUrl = () => - process.env['NODE_ENV'] === 'development' && isWebAppPlatform() - ? '/api' - : `${process.env['NEXT_PUBLIC_API_BASE_URL'] ?? READEST_WEB_BASE_URL}/api`; + process.env['NODE_ENV'] === 'development' && isWebAppPlatform() ? '/api' : `${getBaseUrl()}/api`; export interface EnvConfigType { getAppService: () => Promise;