I tried to secure my ngrok tunnels with name and password but run in some problem on my proxy.
If I try to set the variable for that depended on the header from the request, similar to the router.
var optionsLogin = {
logLevel: 'debug',
changeOrigin: true,
target: 'not reachable',
auth: function (proxyRequest, path, req) {
const endpoint= proxyRequest.headers.endpoint;
const pwd= await redis.getValue(endpoint.toUpperCase() + _'pwd');
return endpoint + ':' + pwd;
},
router: async function (proxyRequest, path, req) {
const endpoint= proxyRequest.headers.endpoint
const domain = await redis.getValue(endpoint.toUpperCase())
return 'https://' + domain;
},
};
Unfortunately, this does not work:
TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received function auth
The docu https://www.npmjs.com/package/http-proxy-middleware gives me no idea what to do.
I also tried this
var optionsLogin = {
logLevel: 'debug',
changeOrigin: true,
target: 'not reachable',
router: async function (proxyRequest, path, req) {
const company = proxyRequest.headers.company
console.log(company)
const domain = await redis.getValue(company.toUpperCase())
return 'https://exampleEndpoint:password@'+ domain;
},
};
What seems to go into the wrong direction.
Can somebody help me with this or has an idea?