Open tomsaleeba opened 6 years ago
@tomsaleeba This makes sense, thanks for the heads up! If you have a moment to send a PR, I'll review and merge
@mikermcneil here's your PR: https://github.com/balderdashy/sails/pull/4745
@tomsaleeba Your PR has been merged! Thanks again. 👍
(leaving it open until it's published)
Sails version: 1.0.3-2 Node version: 8.10 NPM version: 5.6.0 DB adapter name: sails-disk DB adapter version: 2.0.1 (part of sails-hook-orm) Operating system: Linux Mint 18.3
Steps:
content-type
header and returns a JS object not a string, something like:content-type
header is what you setExpected: The header comes through as you set it.
Actual: Our header gets overwritten because we returned a JS object, not a string, and https://github.com/balderdashy/sails/blob/635ec44316f797237019dfc5b1e14b8085eb960f/lib/router/res.js#L264 overwrote it.
The work around is to stringify the response in the custom response, like
JSON.stringify(optionalData)
.The point is that Express doesn't behave like this. I can send a JS object while setting
content-type
and it works. Is it worth modifyingres.js:264
to only setcontent-type
only when it's not already set?I'm happy to provide a concrete example of this running or send a PR with the fix. Just wanted to discuss it first.