javascript - How can I set response header on express.js assets - Stack Overflow
res.setHeader() is a native method of Node.js and res.header() is an alias of res.set() method from Express framework.
Documentation:
res.setHeader(),res.set()
This two methods do exactly the same thing, set the headers HTTP response. The only difference is res.setHeader() allows you only to set a singular header and res.header() will allow you to set multiple headers. So use the one fit with your needs.
res.set(field [, value])
Sets the response’s HTTP header field to value. To set multiple fields at once, pass an object as the parameter.
res.set('Content-Type', 'text/plain')
res.set({
'Content-Type': 'text/plain',
'Content-Length': '123',
ETag: '12345'
})
Aliased as res.header(field [, value]).
Không có nhận xét nào:
Đăng nhận xét