Service async function on onProxyReq
See original GitHub issueHaving proxy configured with onProxyReq
like:
proxy(gatewayUrl, {
target: destinationUrl,
pathRewrite: { [`^${gatewayUrl}`]: '' },
changeOrigin: true,
logProvider: () => logger,
...options,
onProxyReq: async (proxyReq, req) => await addAuthHeader(proxyReq, req, redis),
});
Middleware is finishing request before promise is resolved. It is possible to service promise in proxy functions ?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:66
- Comments:28 (3 by maintainers)
Top Results From Across the Web
Developers - Service async function on onProxyReq - - Bountysource
Service async function on onProxyReq ... Having proxy configured with onProxyReq like: proxy(gatewayUrl, { target: destinationUrl, pathRewrite: { [`^${gatewayUrl} ...
Read more >Invoking an asynchronous method inside a middleware in ...
I'm trying to create a proxy with node-http-proxy in Node.js that checks whether a request is authorized in a mongodb. Basically, I created...
Read more >http-proxy-middleware - npm
The one-liner node.js proxy middleware for connect, express and browser-sync. Latest version: 2.0.6, last published: 8 months ago.
Read more >http-proxy-middleware: Documentation | Openbase
pathFilter (string, []string, glob, []glob, function) ... function onProxyReq(proxyReq, req, res) { // add custom header to request proxyReq.
Read more >An introduction to API Gateway in NestJS with Microservices ...
async function bootstrap() { ... with Bearer JWT then you could have a service in the API Gateway that confirms that the JWT...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@chimurai I have to deal with promises in both proxyReq and proxyRes functions. Would be very helpful to have to have these functions support promises.
Thanks @dpetrov this works here too. you dont even have to use
onProxyReq
, headers will get forwarded by the proxy later on