mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-12 22:42:13 +02:00
refactor(web): support same-origin backend and zero urls
This commit is contained in:
parent
2373014943
commit
f5d04cf8ba
11 changed files with 62 additions and 36 deletions
|
|
@ -93,11 +93,6 @@ class BaseApiService {
|
|||
},
|
||||
};
|
||||
|
||||
// Validate the base URL
|
||||
if (!this.baseUrl) {
|
||||
throw new AppError("Base URL is not set.");
|
||||
}
|
||||
|
||||
// Validate the bearer token
|
||||
const isNoAuthEndpoint =
|
||||
this.noAuthEndpoints.includes(url) ||
|
||||
|
|
@ -107,8 +102,8 @@ class BaseApiService {
|
|||
throw new AuthenticationError("You are not authenticated. Please login again.");
|
||||
}
|
||||
|
||||
// Construct the full URL
|
||||
const fullUrl = new URL(url, this.baseUrl).toString();
|
||||
// Construct the full URL. Empty baseUrl is valid for same-origin proxy mode.
|
||||
const fullUrl = this.baseUrl ? new URL(url, this.baseUrl).toString() : url;
|
||||
|
||||
// Prepare fetch options
|
||||
const fetchOptions: RequestInit = {
|
||||
|
|
|
|||
|
|
@ -15,9 +15,18 @@ import packageJson from "../package.json";
|
|||
// Placeholder: __NEXT_PUBLIC_FASTAPI_BACKEND_AUTH_TYPE__
|
||||
export const AUTH_TYPE = process.env.NEXT_PUBLIC_FASTAPI_BACKEND_AUTH_TYPE || "GOOGLE";
|
||||
|
||||
// Backend API URL
|
||||
// Backend API URL. An empty string is valid in proxy mode and means
|
||||
// same-origin relative requests (e.g. /api/v1/... and /auth/...).
|
||||
// Placeholder: __NEXT_PUBLIC_FASTAPI_BACKEND_URL__
|
||||
export const BACKEND_URL = process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL || "http://localhost:8000";
|
||||
export const BACKEND_URL = process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL ?? "http://localhost:8000";
|
||||
|
||||
// Server-side backend URL. Relative browser URLs do not work from RSC/API route
|
||||
// code, so server callers should use Docker DNS or an explicit public backend.
|
||||
export const SERVER_BACKEND_URL =
|
||||
process.env.FASTAPI_BACKEND_INTERNAL_URL ||
|
||||
process.env.BACKEND_URL ||
|
||||
BACKEND_URL ||
|
||||
"http://localhost:8000";
|
||||
|
||||
// ETL Service: "DOCLING", "UNSTRUCTURED", or "LLAMACLOUD"
|
||||
// Placeholder: __NEXT_PUBLIC_ETL_SERVICE__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue