mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-25 19:15:18 +02:00
Merge remote-tracking branch 'upstream/dev' into feat/replace-logs
This commit is contained in:
commit
9b9fde955f
6 changed files with 41 additions and 8 deletions
|
|
@ -9,6 +9,7 @@ import { useEffect, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { loginMutationAtom } from "@/atoms/auth/auth-mutation.atoms";
|
import { loginMutationAtom } from "@/atoms/auth/auth-mutation.atoms";
|
||||||
import { getAuthErrorDetails, isNetworkError, shouldRetry } from "@/lib/auth-errors";
|
import { getAuthErrorDetails, isNetworkError, shouldRetry } from "@/lib/auth-errors";
|
||||||
|
import { AUTH_TYPE } from "@/lib/env-config";
|
||||||
import { ValidationError } from "@/lib/error";
|
import { ValidationError } from "@/lib/error";
|
||||||
import { trackLoginAttempt, trackLoginFailure, trackLoginSuccess } from "@/lib/posthog/events";
|
import { trackLoginAttempt, trackLoginFailure, trackLoginSuccess } from "@/lib/posthog/events";
|
||||||
|
|
||||||
|
|
@ -30,8 +31,8 @@ export function LocalLoginForm() {
|
||||||
const [{ mutateAsync: login, isPending: isLoggingIn }] = useAtom(loginMutationAtom);
|
const [{ mutateAsync: login, isPending: isLoggingIn }] = useAtom(loginMutationAtom);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Get the auth type from environment variables
|
// Get the auth type from centralized config
|
||||||
setAuthType(process.env.NEXT_PUBLIC_FASTAPI_BACKEND_AUTH_TYPE || "GOOGLE");
|
setAuthType(AUTH_TYPE);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleSubmit = async (e: React.FormEvent) => {
|
const handleSubmit = async (e: React.FormEvent) => {
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import { Suspense, useEffect, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { Logo } from "@/components/Logo";
|
import { Logo } from "@/components/Logo";
|
||||||
import { getAuthErrorDetails, shouldRetry } from "@/lib/auth-errors";
|
import { getAuthErrorDetails, shouldRetry } from "@/lib/auth-errors";
|
||||||
|
import { AUTH_TYPE } from "@/lib/env-config";
|
||||||
import { AmbientBackground } from "./AmbientBackground";
|
import { AmbientBackground } from "./AmbientBackground";
|
||||||
import { GoogleLoginButton } from "./GoogleLoginButton";
|
import { GoogleLoginButton } from "./GoogleLoginButton";
|
||||||
import { LocalLoginForm } from "./LocalLoginForm";
|
import { LocalLoginForm } from "./LocalLoginForm";
|
||||||
|
|
@ -82,8 +83,8 @@ function LoginContent() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the auth type from environment variables
|
// Get the auth type from centralized config
|
||||||
setAuthType(process.env.NEXT_PUBLIC_FASTAPI_BACKEND_AUTH_TYPE || "GOOGLE");
|
setAuthType(AUTH_TYPE);
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}, [searchParams, t, tCommon]);
|
}, [searchParams, t, tCommon]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import { toast } from "sonner";
|
||||||
import { registerMutationAtom } from "@/atoms/auth/auth-mutation.atoms";
|
import { registerMutationAtom } from "@/atoms/auth/auth-mutation.atoms";
|
||||||
import { Logo } from "@/components/Logo";
|
import { Logo } from "@/components/Logo";
|
||||||
import { getAuthErrorDetails, isNetworkError, shouldRetry } from "@/lib/auth-errors";
|
import { getAuthErrorDetails, isNetworkError, shouldRetry } from "@/lib/auth-errors";
|
||||||
|
import { AUTH_TYPE } from "@/lib/env-config";
|
||||||
import { AppError, ValidationError } from "@/lib/error";
|
import { AppError, ValidationError } from "@/lib/error";
|
||||||
import {
|
import {
|
||||||
trackRegistrationAttempt,
|
trackRegistrationAttempt,
|
||||||
|
|
@ -36,8 +37,7 @@ export default function RegisterPage() {
|
||||||
|
|
||||||
// Check authentication type and redirect if not LOCAL
|
// Check authentication type and redirect if not LOCAL
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const authType = process.env.NEXT_PUBLIC_FASTAPI_BACKEND_AUTH_TYPE || "GOOGLE";
|
if (AUTH_TYPE !== "LOCAL") {
|
||||||
if (authType !== "LOCAL") {
|
|
||||||
router.push("/login");
|
router.push("/login");
|
||||||
}
|
}
|
||||||
}, [router]);
|
}, [router]);
|
||||||
|
|
|
||||||
|
|
@ -425,6 +425,8 @@ export default function NewChatPage() {
|
||||||
const newThread = await createThread(searchSpaceId, "New Chat");
|
const newThread = await createThread(searchSpaceId, "New Chat");
|
||||||
currentThreadId = newThread.id;
|
currentThreadId = newThread.id;
|
||||||
setThreadId(currentThreadId);
|
setThreadId(currentThreadId);
|
||||||
|
// Set currentThread so ChatHeader can show share button immediately
|
||||||
|
setCurrentThread(newThread);
|
||||||
|
|
||||||
// Track chat creation
|
// Track chat creation
|
||||||
trackChatCreated(searchSpaceId, currentThreadId);
|
trackChatCreated(searchSpaceId, currentThreadId);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import Image from "next/image";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import React, { useEffect, useRef, useState } from "react";
|
import React, { useEffect, useRef, useState } from "react";
|
||||||
import Balancer from "react-wrap-balancer";
|
import Balancer from "react-wrap-balancer";
|
||||||
|
import { AUTH_TYPE, BACKEND_URL } from "@/lib/env-config";
|
||||||
import { trackLoginAttempt } from "@/lib/posthog/events";
|
import { trackLoginAttempt } from "@/lib/posthog/events";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
|
@ -134,11 +135,11 @@ export function HeroSection() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function GetStartedButton() {
|
function GetStartedButton() {
|
||||||
const isGoogleAuth = process.env.NEXT_PUBLIC_FASTAPI_BACKEND_AUTH_TYPE === "GOOGLE";
|
const isGoogleAuth = AUTH_TYPE === "GOOGLE";
|
||||||
|
|
||||||
const handleGoogleLogin = () => {
|
const handleGoogleLogin = () => {
|
||||||
trackLoginAttempt("google");
|
trackLoginAttempt("google");
|
||||||
window.location.href = `${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/auth/google/authorize-redirect`;
|
window.location.href = `${BACKEND_URL}/auth/google/authorize-redirect`;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isGoogleAuth) {
|
if (isGoogleAuth) {
|
||||||
|
|
|
||||||
28
surfsense_web/lib/env-config.ts
Normal file
28
surfsense_web/lib/env-config.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
/**
|
||||||
|
* Environment configuration for the frontend.
|
||||||
|
*
|
||||||
|
* This file centralizes access to NEXT_PUBLIC_* environment variables.
|
||||||
|
* For Docker deployments, these placeholders are replaced at container startup
|
||||||
|
* via sed in the entrypoint script.
|
||||||
|
*
|
||||||
|
* IMPORTANT: Do not use template literals or complex expressions with these values
|
||||||
|
* as it may prevent the sed replacement from working correctly.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Auth type: "LOCAL" for email/password, "GOOGLE" for OAuth
|
||||||
|
// Placeholder: __NEXT_PUBLIC_FASTAPI_BACKEND_AUTH_TYPE__
|
||||||
|
export const AUTH_TYPE = process.env.NEXT_PUBLIC_FASTAPI_BACKEND_AUTH_TYPE || "GOOGLE";
|
||||||
|
|
||||||
|
// Backend API URL
|
||||||
|
// Placeholder: __NEXT_PUBLIC_FASTAPI_BACKEND_URL__
|
||||||
|
export const BACKEND_URL = process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL || "http://localhost:8000";
|
||||||
|
|
||||||
|
// ETL Service: "DOCLING" or "UNSTRUCTURED"
|
||||||
|
// Placeholder: __NEXT_PUBLIC_ETL_SERVICE__
|
||||||
|
export const ETL_SERVICE = process.env.NEXT_PUBLIC_ETL_SERVICE || "DOCLING";
|
||||||
|
|
||||||
|
// Helper to check if local auth is enabled
|
||||||
|
export const isLocalAuth = () => AUTH_TYPE === "LOCAL";
|
||||||
|
|
||||||
|
// Helper to check if Google auth is enabled
|
||||||
|
export const isGoogleAuth = () => AUTH_TYPE === "GOOGLE";
|
||||||
Loading…
Add table
Add a link
Reference in a new issue