code: function replaceResponse(res) {
    // copy for response.headers.hasOwnProperty is undefined case
    // https://github.com/oauthjs/node-oauth2-server/pull/486
    const newResponse = {
      headers: {},
    };
    for (const property in res) {
      if (property !== 'headers') {
        newResponse[property] = res[property];
      }
    }
    for (const field in res.headers) {
      newResponse.headers[field] = res.headers[field];
    }
    newResponse.header = newResponse.headers;
    return newResponse;
  }
docs: replace response.