Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • N node-http-proxy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 482
    • Issues 482
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 102
    • Merge requests 102
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • http ... PARTY!
  • node-http-proxy
  • Issues
  • #908
Closed
Open
Issue created Nov 16, 2015 by Administrator@rootContributor

Running 'setHeader' during 'proxyReq' event fails for POST requests

Created by: cdl

Right now, it looks like trying to do a setHeader on the passed in proxyReq for POST requests fails. (see below:)

proxy.on('proxyReq', function(proxyReq, req, res, options) {
  proxyReq.setHeader('origin', 'https://example.com');
});

The following error is thrown when the above tries to execute:

Error: Can't set headers after they are sent.

This seems to work totally fine for GET requests, just not POST requests. Managed to hack around it at first by wrapping the .setHeader call in check to make sure proxyReq._header was null, but it looks like that totally fails when Firefox tries to perform a POST request (the header doesn't get set).

The same thing appears to happen when trying to do res.setHeader, as suggested by #819.

Assignee
Assign to
Time tracking