1

I am trying to proxy requests with craco config. however the proxy seems to be ignored. Why is it not working?

I have a create-react-app project that I started using:

npx create-react-app check-proxy-config --template typescript

and I've added craco to it:

npm i -D @craco/craco

In addition I defined a proxy in craco.config.cjs file:

module.exports = {
    webpack: {
        devServer: {
            logLevel: "debug",
            proxy: {

                "/api": {
                    target: "https://<any Domain whatsoever>",
                    logLevel: "debug",
                    secure: true, // false
                    changeOrigin: true, //false
                    bypass: function(req, res, options) {
                        console.debug("bypass");
                    },
                    onProxyReq: function(proxyReq, req, res) {
                        console.debug(`Proxying request: ${req.originalUrl} => ${proxyReq.path}`);
                    }
                }
            }
        },

The request I'm sending from the browser is: http://localhost:3000/api/something

None of the console.debug statements is printed. Why? how can I make the proxy work?

Noy Oliel
  • 1,430
  • 3
  • 13
  • 26

1 Answers1

0

The configuration worked after checking in the backend server i was able to ensure there was no issue with the config, hoewever the "on" methods (i.e. onProxyReq, etc) are not being called

Noy Oliel
  • 1,430
  • 3
  • 13
  • 26