mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-25 19:15:18 +02:00
refactor(env): replace inline process.env reads with BACKEND_URL in lib/
This commit is contained in:
parent
8174949b38
commit
1fbb8fb58d
3 changed files with 7 additions and 10 deletions
|
|
@ -9,7 +9,7 @@ import {
|
||||||
NetworkError,
|
NetworkError,
|
||||||
NotFoundError,
|
NotFoundError,
|
||||||
} from "../error";
|
} from "../error";
|
||||||
|
import { BACKEND_URL } from "@/lib/env-config";
|
||||||
enum ResponseType {
|
enum ResponseType {
|
||||||
JSON = "json",
|
JSON = "json",
|
||||||
TEXT = "text",
|
TEXT = "text",
|
||||||
|
|
@ -390,4 +390,4 @@ class BaseApiService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const baseApiService = new BaseApiService(process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL || "");
|
export const baseApiService = new BaseApiService(BACKEND_URL);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Authentication utilities for handling token expiration and redirects
|
* Authentication utilities for handling token expiration and redirects
|
||||||
*/
|
*/
|
||||||
|
import { BACKEND_URL } from "@/lib/env-config";
|
||||||
const REDIRECT_PATH_KEY = "surfsense_redirect_path";
|
const REDIRECT_PATH_KEY = "surfsense_redirect_path";
|
||||||
const BEARER_TOKEN_KEY = "surfsense_bearer_token";
|
const BEARER_TOKEN_KEY = "surfsense_bearer_token";
|
||||||
const REFRESH_TOKEN_KEY = "surfsense_refresh_token";
|
const REFRESH_TOKEN_KEY = "surfsense_refresh_token";
|
||||||
|
|
@ -194,8 +194,7 @@ export async function logout(): Promise<boolean> {
|
||||||
// Call backend to revoke the refresh token
|
// Call backend to revoke the refresh token
|
||||||
if (refreshToken) {
|
if (refreshToken) {
|
||||||
try {
|
try {
|
||||||
const backendUrl = process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL || "http://localhost:8000";
|
const response = await fetch(`${BACKEND_URL}/auth/jwt/revoke`, {
|
||||||
const response = await fetch(`${backendUrl}/auth/jwt/revoke`, {
|
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
|
@ -273,8 +272,7 @@ export async function refreshAccessToken(): Promise<string | null> {
|
||||||
isRefreshing = true;
|
isRefreshing = true;
|
||||||
refreshPromise = (async () => {
|
refreshPromise = (async () => {
|
||||||
try {
|
try {
|
||||||
const backendUrl = process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL || "http://localhost:8000";
|
const response = await fetch(`${BACKEND_URL}/auth/jwt/refresh`, {
|
||||||
const response = await fetch(`${backendUrl}/auth/jwt/refresh`, {
|
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { baseApiService } from "@/lib/apis/base-api.service";
|
import { baseApiService } from "@/lib/apis/base-api.service";
|
||||||
|
import { BACKEND_URL } from "@/lib/env-config";
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
// Types matching backend schemas
|
// Types matching backend schemas
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
@ -228,6 +228,5 @@ export interface RegenerateParams {
|
||||||
* Get the URL for the regenerate endpoint (for streaming fetch)
|
* Get the URL for the regenerate endpoint (for streaming fetch)
|
||||||
*/
|
*/
|
||||||
export function getRegenerateUrl(threadId: number): string {
|
export function getRegenerateUrl(threadId: number): string {
|
||||||
const backendUrl = process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL || "http://localhost:8000";
|
return `${BACKEND_URL}/api/v1/threads/${threadId}/regenerate`;
|
||||||
return `${backendUrl}/api/v1/threads/${threadId}/regenerate`;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue