When specified, “proxy” in package.json must be a string

The issue that you are facing is because of CRA v2.

Firstly, you will not require any additional configuration if you are just using a plain string in your proxy. But the moment you use an object, you are using advanced configuration.

So, you would have to follow the steps listed below:

  1. Install http-proxy-middleware by typing npm i --save http-proxy-middleware

  2. Remove the entries from package.json:

"proxy": {
    "https://stackoverflow.com/auth/google": {
        "target": "http://localhost:5000"
    }
}
  1. Now create a setup file for your proxy. You should name it setupProxy.js in your src folder on the client side and type the following code:
const proxy = require('http-proxy-middleware');
module.exports = function(app) {
    app.use(proxy("https://stackoverflow.com/auth/google", 
        { target: 'http://localhost:5000/' }
    ));
}

for more info check this

Leave a Comment