Skip to content

Upgrading from react-script 3.3.1 to react-scripts 3.4.0 required changing setupProxy #8513

Description

@breathe

Not 100% sure why -- but after upgrading to react-scripts 3.4.0 it became necessary for me to change the way that I'm requiring the http proxy ...

The instructions from here -- https://create-react-app.dev/docs/proxying-api-requests-in-development/ -- fail with 'proxy is not a function'

I had to change this code (which was working before ...):

const proxy = require("http-proxy-middleware");
const setupBackend = require("./setupBackend");
const target = setupBackend();
module.exports = function(app) {
console.log("Setting up proxy url's on development server");
app.use(
["/token_api", "/__meta_request"],
proxy({
target,
changeOrigin: true,
preserveHeaderKeyCase: false
})
);
};

To this:

const proxy = require("http-proxy-middleware").createProxyMiddleware;
const setupBackend = require("./setupBackend");
const target = setupBackend();
module.exports = function(app) {
console.log("Setting up proxy url's on development server");
app.use(
["/token_api", "/__meta_request"],
proxy({
target,
changeOrigin: true,
preserveHeaderKeyCase: false
})
);
};

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions