11

How can I view detailed logs of all requests and responses being handled by the proxy used by create-react-app?

I don't only want to log some endpoints. Instead, I want to see everything, in as much detail as possible, about what's going through the proxy.

The reason is that I'm getting 403 errors back from the AWS API Gateway server but I'm having trouble reproducing the problem via browser, curl, etc. So I want to get ahold of the actual headers and content going over the wire, to see if my problem might be proxy-related.

Justin Grant
  • 41,265
  • 11
  • 110
  • 185

1 Answers1

0

In Create-react-app you can use a custom proxy which is an instance of http-proxy-middleware.

const { createProxyMiddleware } = require('http-proxy-middleware');

module.exports = function(app) {
  app.use(
    '/api',
    createProxyMiddleware({
      target: 'http://localhost:5000',
      changeOrigin: true,
    })
  );
};

So you can implement your own LogProvider and Errors events

Hamid Osouli
  • 458
  • 3
  • 17