CORSProxy install

Submitted by code_admin on Wed, 07/25/2018 - 15:47

On windows I found corsproxy files to hack:
C:\Users\rjmetcal\AppData\Roaming\npm\node_modules\corsproxy-https

Running for particular server URL

I made a bat file called 'rjmcorsproxy' as follows:

  1. set CORSPROXY_HOST=cc-rjmetcal
  2. corsproxy

Hack of corsproxy-https to ignore cert errors

Edit C:\Users\rjmetcal\AppData\Roaming\npm\node_modules\corsproxy-https\bin\corsproxy

In proxy.route add rejectUnauthorized: false

  1. proxy.route({
  2.   method: '*',
  3.   path: '/{host}/{path*}',
  4.   handler: {
  5.     proxy: {
  6.       passThrough: true,
  7.       rejectUnauthorized: false,
  8.       mapUri: function (request, callback) {
  9.         request.host = request.params.host
  10.         request.path = request.path.substr(request.params.host.length + 1)
  11.         request.headers['host'] = request.host
  12.         var query = request.url.search ? request.url.search : ''
  13.         var scheme = request.url.scheme
  14.         console.log('proxy to https://' + request.host + request.path)
  15.         callback(null, 'https://' + request.host + request.path + query, request.headers)
  16.       }
  17.     }
  18.   },
  19.   config: {
  20.     payload: {
  21.       maxBytes: maxPayload
  22.     }
  23.   }
  24. })

Tags

RJM Article Type
Work Notes