fix(xo-server/xo.exportConfig): dont return 200 on failure

`writeHead` sends immediatly the response header, which has a number of undesirable side-effects.

For instance, in this case, it prevented returning a 500 code in case of error.

It's almost always preferable to use `statusCode`, `writeHead()` or Express methods like `set()`.
This commit is contained in:
Julien Fontanet 2020-04-17 16:12:55 +02:00
parent c79ebfdd0a
commit ec899be3b5

View File

@ -18,7 +18,7 @@ export async function exportConfig() {
return {
$getFrom: await this.registerHttpRequest(
(req, res) => {
res.writeHead(200, 'OK', {
res.set({
'content-disposition': 'attachment',
'content-type': 'application/json',
})