mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 19:33:11 +02:00
fix: doubled base path in mobile-scanner QR URL
A configured frontendUrl/server_url already includes the subpath (e.g. /bpp), but the code also applied withBasePath, producing /bpp/bpp/... Append the route directly to a configured URL; reserve withBasePath for the bare-origin fallback. Matches the ShareFileModal convention.
This commit is contained in:
@@ -83,11 +83,27 @@ export default function MobileUploadModal({
|
|||||||
const timerIntervalRef = useRef<number | null>(null);
|
const timerIntervalRef = useRef<number | null>(null);
|
||||||
const processedFiles = useRef<Set<string>>(new Set());
|
const processedFiles = useRef<Set<string>>(new Set());
|
||||||
|
|
||||||
// Use configured frontendUrl if set, otherwise use current origin
|
// A configured server_url/frontendUrl already includes any subpath, so append
|
||||||
// Combine with base path and mobile-scanner route
|
// the route directly; only the bare-origin fallback needs withBasePath.
|
||||||
const baseUrl = localStorage.getItem("server_url") || "";
|
const configuredUrl = (
|
||||||
const frontendUrl = baseUrl || config?.frontendUrl || window.location.origin;
|
localStorage.getItem("server_url") ||
|
||||||
const mobileUrl = `${frontendUrl}${withBasePath("/mobile-scanner")}?session=${sessionId}`;
|
config?.frontendUrl ||
|
||||||
|
""
|
||||||
|
).trim();
|
||||||
|
let mobileBase = "";
|
||||||
|
if (configuredUrl) {
|
||||||
|
try {
|
||||||
|
const parsed = new URL(configuredUrl);
|
||||||
|
if (parsed.protocol === "http:" || parsed.protocol === "https:") {
|
||||||
|
mobileBase = configuredUrl.replace(/\/$/, "");
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// invalid configured URL — fall back to origin
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const mobileUrl = mobileBase
|
||||||
|
? `${mobileBase}/mobile-scanner?session=${sessionId}`
|
||||||
|
: `${window.location.origin}${withBasePath("/mobile-scanner")}?session=${sessionId}`;
|
||||||
|
|
||||||
// Create session on backend
|
// Create session on backend
|
||||||
const createSession = useCallback(
|
const createSession = useCallback(
|
||||||
|
|||||||
Reference in New Issue
Block a user