Closed bsdkurt closed 4 years ago
Seems to have been declared as depreciation since Node.js 8 (documentation-only) : https://nodejs.org/api/deprecations.html#deprecations_dep0066_outgoingmessage_prototype_headers_outgoingmessage_prototype_headernames
The OutgoingMessage.prototype._headers and OutgoingMessage.prototype._headerNames properties were never documented as officially supported properties.
The above link says that OutgoingMessage.prototype.getHeaders()
, OutgoingMessage.prototype.setHeader()
should be used instead.
Node version: v12.18.0 I am getting the same issue. http://localhost:3000/index.html is blank even after log files are generated
Those who are facing this problem in FreeCodeCamp
exercise, the issue is in the server.js
file. The solution is to replace ._headers
with .getHeaders()
, as the error is telling us that ._headers
has been deprecated.
e.g. in server.js
, instead of -
// filter out CORS Headers
var hs = Object.keys(res._headers)
.filter(h => !h.match(/^access-control-\w+/));
var hObj = {};
hs.forEach(h => {hObj[h] = res._headers[h]});
delete res._headers['strict-transport-security'];
use the following -
// filter out CORS Headers
var hs = Object.keys(res.getHeaders())
.filter(h => !h.match(/^access-control-\w+/));
var hObj = {};
hs.forEach(h => {hObj[h] = res.getHeaders()[h]});
delete res.getHeaders()['strict-transport-security'];
Summary: replace all ._headers
with .getHeaders()
.
npm i browser-sync
try to run this ,it worked for me.
I still have the same issue and I am unable to find the server.js file in node. node: v18.12.1 OS: Win 10 Pro http-server: v14.1.1
(node:12892) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
(Use node --trace-deprecation ...
to show where the warning was created)
Using aws lambda nodejs12.x runtime with serverless-http 2.3.0 generates the following warning:
Presumably due to the use of _headers in libs/response.js.