Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to change 'content-type' header of request #526

Open
harsh-niyo opened this issue Sep 10, 2023 · 2 comments
Open

Unable to change 'content-type' header of request #526

harsh-niyo opened this issue Sep 10, 2023 · 2 comments
Assignees

Comments

@harsh-niyo
Copy link

harsh-niyo commented Sep 10, 2023

I have written a proxy server using nestjs and express-rest-proxy. I want to change the content-type header of the request. I am using proxyReqOptDecorator to do the same, but it is not updating the header of the request.
Is there something that I'm doing anything incorrectly or is this a bug?

Version - 2.0.0

Code sample:

const proxyMiddleware: ProxyMiddleware =
    app.get<ProxyMiddleware>(ProxyMiddleware);
  app.use(
    configService.get<string>('liquiLoans.path'),
    proxy(configService.get<string>('liquiLoans.baseUrl'), {
      https: true,
      memoizeHost: false,
      limit: 10 * 1024 * 1024,
      proxyReqOptDecorator: (proxyReqOpts, _srcReq) => {
        proxyReqOpts.headers['content-type'] = 'multipart/form-data';
        return proxyReqOpts;
      },
      proxyReqBodyDecorator: proxyMiddleware.bodyDecorator.bind(
        proxyMiddleware,
      ),
      proxyErrorHandler: proxyMiddleware.proxyErrorHandler.bind(
        proxyMiddleware,
      ),
      userResDecorator: proxyMiddleware.responseDecorator.bind(
        proxyMiddleware,
      ),
      proxyReqPathResolver: proxyMiddleware.pathResolver.bind(
        proxyMiddleware,
      ),
      reqAsBuffer: false,
    }),
  );;
@monkpow
Copy link
Collaborator

monkpow commented Sep 11, 2023

Thanks for the question. I'm looking into this.

@monkpow
Copy link
Collaborator

monkpow commented Sep 11, 2023

This appear to me to work as expected (at least in the test suite). Can you give more information about what you see when this is not working?

#527

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants