Sails.js
app uses a default favicon from express. I want to replace it with my own one but have struggled with it for a couple of hours.
I have tried to add a separate favicon.js
with following code under config folder, but without 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 following line in the view template will work in both Chrome and Fire Fox, but not in Safari (OSX), don't know why.
<link rel="icon" href="/img/icon_fav.png" type='image/png'>
Also tried to put /favicon.ico
under web server root.
Googled for this, and it seems no one asked before.
Can someone point me to a solution?
What i did to update the favicon is put a version behind it.
<link rel="icon" href="/img/icon_fav.png?version=2" type="image/png">
Put icon in root folder and use:
<link rel="icon" href="favicon.ico" type="image/x-icon">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With