I want to debugging in the localhost:3000 port when develop a react app, my server api address is admin.example.com, I config like this in the project src/setupProxy.js file:
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = function(app) {
app.use(createProxyMiddleware('/\/manage\/?$/',
{
target: 'https://admin.example.com/',
changeOrigin: true
}));
};
but when I start the app, still give me tips that the XHR was cross origin. what should I do to make it work? Am I missing something? this is the http-proxy-middleware version "http-proxy-middleware": "^2.0.1". the full request url is: https://admin.example.com/manage/dashboard/overview.
Please try this: Here is the setupProxy.js file:
const proxy = require("http-proxy-middleware");
module.exports = function(app) {
app.use(proxy("/manage", { target: "https://admin.example.com/" }));
}
API request example:
app.post("manage/login", requireSignIn, Authentication.login);