systemjs / systemjs

Dynamic ES module loader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

setupProxy.js file not working in single-spa-react

ram97510 opened this issue · comments

setupProxy.js

const { createProxyMiddleware } = require("http-proxy-middleware");
module.exports = function (app) {
app.use(
"/3",
createProxyMiddleware({
target:
"http://localhost:3000/",
headers: {
method: "GET",
},
changeOrigin: true,
})
);
};

root.component.js

const getLocalHostAPI1 = async () => {
try {
const result = await fetch("/3");
const data = await result.json();
console.log(data)
setApi1Response(JSON.stringify(data));
} catch (error) {
console.error("Error fetching API", error);
}
};

no error display in the project but /3 path cannot get data then /3 proxy path not working in single-spa-react. so please fix my problem