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:
@@ -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
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user