Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Sails.js static asset serving

How can I completely turn off static assets? I was thinking I might be able to 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 turn off static asset serving in the configuration?

like image 456
light24bulbs Avatar asked Mar 17 '23 17:03

light24bulbs


2 Answers

You can turn off serving of static assets by removing the www middleware from the 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'
    ]

  }
};
like image 169
sgress454 Avatar answered Mar 30 '23 03:03

sgress454


You can create a sails app without front-end with the flag --no-frontend

sails new [appName] --no-frontend

This will avoid to create asset folder and grunt tasks.

like image 30
jorgecasar Avatar answered Mar 30 '23 05:03

jorgecasar