skip to Main Content

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.

api

How can add a favicon on the Node.js API with Content-Type: application/json?

2

Answers


  1. 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…)

    Login or Signup to reply.
  2. 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 .

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search