I am using node.js and implementing an API that returns a response as Content-Type: application/json
like this:
module.exports={
api: (req, res) => {
let data = {"data": [1, 2, 3]};
res.status(200).json(data);
}
}
But, there is no favicon that can be viewed when trying that API on the browser. I see another website that can get this done.
How can add a favicon on the Node.js API with Content-Type: application/json
?
2
Answers
You can just add your favicon.ico to the root folder of your API and maybe the browser will pick it up. Otherwise there is no way to have a favicon for API’s (which are not to be viewed in the browser in the first place, so nobody cares about favicons for APIs…)
First , try to put .ico file in public folder
https://phpout.com/wp-content/uploads/2023/05/GsELM.png
Second ,
set the file name
For example if favicon file name is file.ico
then
<link rel="shortcut icon" href="%PUBLIC_URL%/file.ico"/>
hope this will help u .