question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

question: setting dynamic headers

See original GitHub issue

Hi there,

I have a case where I need to setup headers dynamically, e.g.:

response.setHeader("Expires", dateFormat.format("ddd, DD MMM YYYY HH:mm:ss") + " GMT");

If I do that using response object @Res() response: any, I always get error:

(node:29688) UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at ServerResponse.setHeader (_http_outgoing.js:470:11)
    at ServerResponse.header (webpack:///./node_modules/express/lib/response.js?:771:10)
    at eval (webpack:///./node_modules/routing-controllers/driver/express/ExpressDriver.js?:364:32)
    at Array.forEach (<anonymous>)
    at ExpressDriver.handleError (webpack:///./node_modules/routing-controllers/driver/express/ExpressDriver.js?:363:45)
    at eval (webpack:///./node_modules/routing-controllers/RoutingControllers.js?:104:33)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Please advise how to handle this kind of scenario.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
azaslonovcommented, Jun 18, 2020

Indeed, I did not. I missed that part in the docs. Thanks a lot!

1reaction
jotamoraiscommented, Jun 18, 2020

Did you also disable the defaultErrorHandler in the RoutingControllersOptions?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Question: Dynamic Headers
HI, My understanding is Boomi is going to release dynamic headers with Rest connector. With dynamic header I mean the header key name...
Read more >
Creating Dynamic Column Headers | Tableau Software
Question. How to create dynamic column headers in a dashboard using parameters and calculated fields. Environment. Tableau Desktop. Answer.
Read more >
How to create/set dynamic headers in tabulator
You can enable this by setting the autoColumns option to true: var table = new Tabulator("#example-table", { data:tabledata, ...
Read more >
How to create/set dynamic headers in tabulator · Issue #2490
Hello, How can we set dynamic header name. is is being passed from JSON. Also I want to know how can we hide...
Read more >
Can you dynamically set Headers for integration tests? - Help
My question: Is it possible to dynamically set headers during integration tests? Meaning: request is made multiple times during tests so ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found