Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ram97510 opened this issue Jun 22, 2023 · 0 comments
Open

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

ram97510 opened this issue Jun 22, 2023 · 0 comments

Comments

@ram97510
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant