1
0
mirror of https://github.com/alexandrev/xslt-lab.git synced 2026-09-20 04:23:16 +00:00

feat: make backend URL configurable

This commit is contained in:
2025-07-01 18:06:44 +02:00
parent 1f76646d20
commit 45f734a444
4 changed files with 24 additions and 3 deletions
+2
View File
@@ -1,5 +1,7 @@
# Stage 1: build the frontend
FROM node:20-alpine AS build
ARG VITE_BACKEND_URL
ENV VITE_BACKEND_URL=${VITE_BACKEND_URL}
WORKDIR /app
COPY package.json ./
RUN npm install
+6 -1
View File
@@ -20,13 +20,18 @@ export default function App() {
const [version, setVersion] = useState("1.0");
const [error, setError] = useState("");
const backendBase = (import.meta.env.VITE_BACKEND_URL || "").replace(
/\/$/,
"",
);
const runTransform = debounce(async (xsltText, ver, p) => {
const paramObj = {};
p.forEach((pr) => {
if (pr.name) paramObj[pr.name] = pr.value;
});
try {
const res = await fetch("/transform", {
const res = await fetch(`${backendBase}/transform`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({