I am implementing a nodejs application using sails.js. I want my user to communicate only through https. So for doing that I need to configure my server my way so that with each response it will add a header "Strict-Transport-Security", "max-age=31536000" to tell browser to communicate with HSTS only. Now how I can modify every response header that I am going to send from sails js.I searched the documentation but did not found any help.
相关问题
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- Axios OPTIONS instead of POST Request. Express Res
- Mechanize getting “Errno::ECONNRESET: Connection r
- google-drive can't get push notifications
- How to reimport module with ES6 import
相关文章
- node连接远程oracle报错
- ssl配置问题
- Intermittent “sslv3 alert handshake failure” under
- How can make folder with Firebase Cloud Functions
- @angular-cli install fails with deprecated request
- node.js modify file data stream?
- How to resolve hostname to an ip address in node j
- Transactionally writing files in Node.js
Policies are only applied to the controllers that you explicitly assign them to in
config/policies.js
.Instead of using a policy, try adding an express middleware directly in
config/express.js
, (create the file if it does not already exist). This middleware is applied to ALL controllers. The format is like so:If you have multiple express custom middleware that you want to use, my advice is to keep each middleware function in its own file. I will provide an example, using your middleware along with an additional middleware that accepts some options.
If you try to have multiple files export a function on the 'express.customMiddleware' namespace, I believe only the middleWare of the last file loaded will work. I haven't tried it though.
You should be able to use Sails policies. With this you should be able to create a policy to change the headers being sent back.