Reputation: 607
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?
Upvotes: 5
Views: 3494
Reputation: 194
sail 0.12 actually serves it from public/favion.ico (although the boostrapped framework stores in it assets , and the documentation says it is at assets/favicon.ico
Upvotes: 0
Reputation: 985
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">
Upvotes: 3
Reputation: 1803
Put icon in root folder and use:
<link rel="icon" href="favicon.ico" type="image/x-icon">
Upvotes: 2