Custom middleware is a legacy option, since most times you just want to use policies.
HOWEVER! There are times you want to use sails for quick/dirty things you would normally use express for (but you already have sails around, w/e). More pertinently, if you want middleware to run before the static files from your assets
folder are served, policies won't let you do that.
// Put this in `config/express.js`
module.exports.express = {
customMiddleware: function (app) {
app.use(require('../node_modules/sails/node_modules/express').basicAuth('balderdash', 'wickywocky'));
}
};
Keep in mind this technique only works with Express (and your static files are only available that way anyhow)
I am sending
type : "POST",
data: "a",
contentType : "application/x-www-form-urlencoded;charset=ISO-8859-15",
dataType : 'json',
ajax request but I am getting
{ "a": ""} in my back-end in sails.
Since I'm new to sails I have problem regarding writing middlewares.
Please help me in configuring "config/http.js" regarding my ajax requests.
Thanks in advance@mikermcneil