How to add custom favicon to sails.js application?

Sails.jsapplication uses favicon icon by default. I want to replace him with mine, but I fought with him for several hours.

I tried to add a separate one favicon.jswith the following code in the config folder, but with no luck.

/**
* favicon.ico
*/
var favicon = require('static-favicon');
var path = require('path');

module.exports = {
  express: {
    customMiddleware: function(app){
      console.log('loading favicon.'); //executed
      app.use(favicon(path.join(__dirname, 'icon_fav.ico')));
      app.use(function (req, res, next) {
        console.log("installed customMiddleware is used");
        next();
      })
    }
  }

};

By the way, adding the next line in the presentation template will work in both Chrome and Fire Fox, but not in Safari (OSX), I don’t know why.

<link rel="icon" href="/img/icon_fav.png" type='image/png'>

Also tried putting /favicon.icounder the root of the web server.

In search of this, and no one seemed to ask before.
Can someone point me to a solution?

+4
source share
3 answers

, , .

<link rel="icon" href="/img/icon_fav.png?version=2" type="image/png">
+2

:

<link rel="icon" href="favicon.ico" type="image/x-icon">
+1

Sail 0.12 actually serves him from public / favion.ico (although assets are stored in the expanded structure, and the documentation says that it is on assets / favicon.ico

0
source

Source: https://habr.com/ru/post/1538528/


All Articles