0

I'm new to Javascript, and it's a mind bending world to me.

I have a [web app] that talks to a [proxy] that talks to a [web service].

In the signature, onProxyRes(proxyRes, req, res), where do each of the parameters originate? It seems like all documentation assumes you already know how it works.

So far, it seems obvious to me req was the original request, does this mean res is the original response? If I am trying to inject headers, should I be updating proxyRes?

I'm having a CORS error, I believe I just need to inject the header...

'Access-Control-Allow-Origin', '*'
Zak
  • 12,213
  • 21
  • 59
  • 105

1 Answers1

0

https://www.npmjs.com/package/http-proxy-middleware indicates how to use this feature.

function onProxyRes(proxyRes, req, res) {
  proxyRes.headers['Access-Control-Allow-Origin'] = '*';
}

should work. However, I haven't gotten my example to work yet, so I am hoping another reply will come in, or you have it figured out now.

Karl Henselin
  • 1,015
  • 12
  • 17