Disable Sails.js Static Assets

How can I completely disable static assets? I thought I could do:

module.exports = {

// Init custom express middleware
express: {

    customMiddleware: function (app) {
        app.use(express.static(__dirname + '/some_empty_folder'));

But that doesn't seem good to me. Is there a way to disable the static asset serving in the configuration?

+4
source share
2 answers

You can disable the display of static assets by removing wwwmiddleware from middleware.order in /config/http.js :

module.exports.http = {

  middleware: {

   order: [
      'startRequestTimer',
      'cookieParser',
      'session',
      'bodyParser',
      'handleBodyParserError',
      'compress',
      'methodOverride',
      'poweredBy',
      '$custom',
      'router',
      // 'www',
      'favicon',
      '404',
      '500'
    ]

  }
};
+3
source

You can create a sails application without an interface with the --no-frontend flag

sails new [appName] --no-frontend

This will avoid creating a folder with resources and completing tasks.

+4
source

All Articles