Route mobile scanner API and vendor loads through the app base path (#6648)

This commit is contained in:
Anthony Stirling
2026-06-12 16:00:11 +01:00
committed by GitHub
parent 63ecbe3b6d
commit eefa8eff61
2 changed files with 11 additions and 4 deletions
@@ -21,6 +21,10 @@ import UploadRoundedIcon from "@mui/icons-material/UploadRounded";
import AddPhotoAlternateRoundedIcon from "@mui/icons-material/AddPhotoAlternateRounded";
import CheckCircleRoundedIcon from "@mui/icons-material/CheckCircleRounded";
import { loadJscanify } from "@app/utils/loadJscanify";
import apiClient from "@app/services/apiClient";
// Use the configured API base (e.g. api.stirling.com), not the page origin.
const API_BASE = (apiClient.defaults.baseURL ?? "").replace(/\/+$/, "");
/**
* MobileScannerPage
@@ -83,7 +87,7 @@ export default function MobileScannerPage() {
try {
const response = await fetch(
`/api/v1/mobile-scanner/validate-session/${sessionId}`,
`${API_BASE}/api/v1/mobile-scanner/validate-session/${sessionId}`,
);
if (response.ok) {
@@ -841,7 +845,7 @@ export default function MobileScannerPage() {
});
const uploadResponse = await fetch(
`/api/v1/mobile-scanner/upload/${sessionId}`,
`${API_BASE}/api/v1/mobile-scanner/upload/${sessionId}`,
{
method: "POST",
body: formData,
@@ -1,3 +1,5 @@
import { withBasePath } from "@app/constants/app";
declare global {
interface Window {
cv?: any;
@@ -5,8 +7,9 @@ declare global {
}
}
const OPENCV_SRC = "/vendor/jscanify/opencv.js";
const JSCANIFY_SRC = "/vendor/jscanify/jscanify.js";
// Served under the app's base path (handles sub-path deploys like /app).
const OPENCV_SRC = withBasePath("/vendor/jscanify/opencv.js");
const JSCANIFY_SRC = withBasePath("/vendor/jscanify/jscanify.js");
let loadPromise: Promise<void> | null = null;