refactor(env): replace inline process.env reads with BACKEND_URL in lib/

This commit is contained in:
Varun Shukla 2026-05-19 00:32:57 +05:30
parent 8174949b38
commit 1fbb8fb58d
3 changed files with 7 additions and 10 deletions

View file

@ -1,7 +1,7 @@
/**
* Authentication utilities for handling token expiration and redirects
*/
import { BACKEND_URL } from "@/lib/env-config";
const REDIRECT_PATH_KEY = "surfsense_redirect_path";
const BEARER_TOKEN_KEY = "surfsense_bearer_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
if (refreshToken) {
try {
const backendUrl = process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL || "http://localhost:8000";
const response = await fetch(`${backendUrl}/auth/jwt/revoke`, {
const response = await fetch(`${BACKEND_URL}/auth/jwt/revoke`, {
method: "POST",
headers: {
"Content-Type": "application/json",
@ -273,8 +272,7 @@ export async function refreshAccessToken(): Promise<string | null> {
isRefreshing = true;
refreshPromise = (async () => {
try {
const backendUrl = process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL || "http://localhost:8000";
const response = await fetch(`${backendUrl}/auth/jwt/refresh`, {
const response = await fetch(`${BACKEND_URL}/auth/jwt/refresh`, {
method: "POST",
headers: {
"Content-Type": "application/json",