mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-14 10:34:06 +02:00
fix: respect BASE_PATH in AI chat fetch and pdfjs worker assets
This commit is contained in:
@@ -8,8 +8,7 @@
|
||||
# Userback feedback widget — leave blank to disable
|
||||
VITE_USERBACK_TOKEN=
|
||||
|
||||
# URL subpath prefix for SaaS deployments (e.g. "app" if serving at /app/) — leave blank for root
|
||||
VITE_RUN_SUBPATH=
|
||||
|
||||
# Development-only auth bypass — allows unauthenticated access on localhost in dev mode
|
||||
# The URL subpath prefix is read from BASE_PATH at runtime, sourced from the
|
||||
# top-level RUN_SUBPATH env var which Vite consumes at build time.
|
||||
VITE_DEV_BYPASS_AUTH=false
|
||||
|
||||
@@ -395,7 +395,11 @@ self.addEventListener(
|
||||
// the default DOMFilterFactory crashes in a worker calling document.createElementNS.
|
||||
// Resolve CMap/standard-font URLs against the worker's own origin. Vite copies these
|
||||
// directories from pdfjs-dist at build time via viteStaticCopy (see vite.config.ts).
|
||||
const assetsBase = new URL("/pdfjs/", self.location.origin).toString();
|
||||
// import.meta.env.BASE_URL ends with a slash and includes any subpath prefix.
|
||||
const assetsBase = new URL(
|
||||
`${import.meta.env.BASE_URL}pdfjs/`,
|
||||
self.location.origin,
|
||||
).toString();
|
||||
const loaderOpts = (data: ArrayBuffer) =>
|
||||
({
|
||||
data,
|
||||
|
||||
@@ -10,6 +10,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { generateId } from "@app/utils/generateId";
|
||||
import { useAllFiles, useFileActions } from "@app/contexts/FileContext";
|
||||
import apiClient from "@app/services/apiClient";
|
||||
import { getApiBaseUrl } from "@app/services/apiClientConfig";
|
||||
import { getAuthHeaders } from "@app/services/apiClientSetup";
|
||||
import { createChildStub } from "@app/contexts/file/fileActions";
|
||||
import {
|
||||
@@ -461,13 +462,16 @@ export function ChatProvider({ children }: { children: ReactNode }) {
|
||||
formData.append(`conversationHistory[${i}].content`, message.content);
|
||||
});
|
||||
|
||||
const response = await fetch("/api/v1/ai/orchestrate/stream", {
|
||||
const response = await fetch(
|
||||
`${getApiBaseUrl()}/api/v1/ai/orchestrate/stream`,
|
||||
{
|
||||
method: "POST",
|
||||
body: formData,
|
||||
headers: getAuthHeaders(),
|
||||
credentials: "include",
|
||||
signal: controller.signal,
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
let detail: string | undefined;
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
import { useAllFiles, useFileActions } from "@app/contexts/FileContext";
|
||||
import { generateId } from "@app/utils/generateId";
|
||||
import apiClient from "@app/services/apiClient";
|
||||
import { getApiBaseUrl } from "@app/services/apiClientConfig";
|
||||
import { getAuthHeaders } from "@app/services/apiClientSetup";
|
||||
import { createChildStub } from "@app/contexts/file/fileActions";
|
||||
import {
|
||||
@@ -440,13 +441,16 @@ export function ChatProvider({ children }: { children: ReactNode }) {
|
||||
formData.append(`conversationHistory[${i}].content`, message.content);
|
||||
});
|
||||
|
||||
const response = await fetch("/api/v1/ai/orchestrate/stream", {
|
||||
const response = await fetch(
|
||||
`${getApiBaseUrl()}/api/v1/ai/orchestrate/stream`,
|
||||
{
|
||||
method: "POST",
|
||||
body: formData,
|
||||
headers: getAuthHeaders(),
|
||||
credentials: "include",
|
||||
signal: controller.signal,
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`AI engine request failed: ${response.status}`);
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { URL_TO_TOOL_MAP } from "@app/utils/urlMapping";
|
||||
import { BASE_PATH } from "@app/constants/app";
|
||||
|
||||
const SUBPATH = import.meta.env.VITE_RUN_SUBPATH.replace(/^\/|\/$/g, ""); // "app" or ""
|
||||
// BASE_PATH is "/bpp" or "" (no trailing slash). Strip the leading slash
|
||||
// to match the legacy SUBPATH shape used below ("bpp" or "").
|
||||
const SUBPATH = BASE_PATH.replace(/^\//, "");
|
||||
|
||||
/**
|
||||
* Normalize pathname by stripping subpath prefix and trailing slashes
|
||||
|
||||
Vendored
-1
@@ -14,7 +14,6 @@ interface ImportMetaEnv {
|
||||
|
||||
// SaaS only (.env.saas)
|
||||
readonly VITE_USERBACK_TOKEN: string;
|
||||
readonly VITE_RUN_SUBPATH: string;
|
||||
readonly VITE_DEV_BYPASS_AUTH: string;
|
||||
|
||||
// Desktop only (.env.desktop)
|
||||
|
||||
Reference in New Issue
Block a user