Node Express “favicon.ico” not found error










1














I'm trying to download a photo through a URL passed as a query string using Express, but every time I try to use it, I get Error: Invalid URI "favicon.ico" Is there a way I can get my browser to stop requesting a favicon? For downloading images, I'm using the image-downloader package (NPM page)



Code:



app.get('/:url', (req, res) => 
let url = req.params.url;
const options =
url: url,
dest: /path'
;
download.image(options)
.then(( filename, image ) =>
console.log('File saved to ', filename);
)
.catch((err) =>
console.log(err);
);
res.send("Done");


);










share|improve this question


























    1














    I'm trying to download a photo through a URL passed as a query string using Express, but every time I try to use it, I get Error: Invalid URI "favicon.ico" Is there a way I can get my browser to stop requesting a favicon? For downloading images, I'm using the image-downloader package (NPM page)



    Code:



    app.get('/:url', (req, res) => 
    let url = req.params.url;
    const options =
    url: url,
    dest: /path'
    ;
    download.image(options)
    .then(( filename, image ) =>
    console.log('File saved to ', filename);
    )
    .catch((err) =>
    console.log(err);
    );
    res.send("Done");


    );










    share|improve this question
























      1












      1








      1







      I'm trying to download a photo through a URL passed as a query string using Express, but every time I try to use it, I get Error: Invalid URI "favicon.ico" Is there a way I can get my browser to stop requesting a favicon? For downloading images, I'm using the image-downloader package (NPM page)



      Code:



      app.get('/:url', (req, res) => 
      let url = req.params.url;
      const options =
      url: url,
      dest: /path'
      ;
      download.image(options)
      .then(( filename, image ) =>
      console.log('File saved to ', filename);
      )
      .catch((err) =>
      console.log(err);
      );
      res.send("Done");


      );










      share|improve this question













      I'm trying to download a photo through a URL passed as a query string using Express, but every time I try to use it, I get Error: Invalid URI "favicon.ico" Is there a way I can get my browser to stop requesting a favicon? For downloading images, I'm using the image-downloader package (NPM page)



      Code:



      app.get('/:url', (req, res) => 
      let url = req.params.url;
      const options =
      url: url,
      dest: /path'
      ;
      download.image(options)
      .then(( filename, image ) =>
      console.log('File saved to ', filename);
      )
      .catch((err) =>
      console.log(err);
      );
      res.send("Done");


      );







      node.js express favicon






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 11 '18 at 22:06









      Apodictic Apple Juice

      994




      994






















          2 Answers
          2






          active

          oldest

          votes


















          1














          It's probably easiest to just make a route for favicon.ico in your server.



          app.get('/favico.ico', (req, res) => 
          res.sendStatus(404);
          );


          Of course, you could actually send a valid icon too if you wanted, but this will at least keep your Express server from showing an error.



          FYI, this has nothing to do with the image-downloader. This has to do with the browser requesting a favico.ico icon that it uses to show in the URL bar (and some other places in the browser UI). If your server returns a 404 for favicon.ico, the browser will use a generic icon in its UI.



          If you want to make yourself a simple favico.ico, you can go here and it will help you generate one and then you can change the above route to:



          app.get('/favico.ico', (req, res) => 
          res.sendFile("myfavico.ico");
          );





          share|improve this answer




























            0














            Try using another package like request module. I believe it got this type of things handled.



            var fs = require('fs'),
            request = require('request');

            var download = function(uri, filename, callback)
            request.head(uri, function(err, res, body)
            console.log('content-type:', res.headers['content-type']);
            console.log('content-length:', res.headers['content-length']);

            request(uri).pipe(fs.createWriteStream(filename)).on('close', callback);
            );
            ;

            download('https://www.google.com/images/srpr/logo3w.png', 'google.png', function()
            console.log('done');
            );





            share|improve this answer




















              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53253723%2fnode-express-favicon-ico-not-found-error%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              It's probably easiest to just make a route for favicon.ico in your server.



              app.get('/favico.ico', (req, res) => 
              res.sendStatus(404);
              );


              Of course, you could actually send a valid icon too if you wanted, but this will at least keep your Express server from showing an error.



              FYI, this has nothing to do with the image-downloader. This has to do with the browser requesting a favico.ico icon that it uses to show in the URL bar (and some other places in the browser UI). If your server returns a 404 for favicon.ico, the browser will use a generic icon in its UI.



              If you want to make yourself a simple favico.ico, you can go here and it will help you generate one and then you can change the above route to:



              app.get('/favico.ico', (req, res) => 
              res.sendFile("myfavico.ico");
              );





              share|improve this answer

























                1














                It's probably easiest to just make a route for favicon.ico in your server.



                app.get('/favico.ico', (req, res) => 
                res.sendStatus(404);
                );


                Of course, you could actually send a valid icon too if you wanted, but this will at least keep your Express server from showing an error.



                FYI, this has nothing to do with the image-downloader. This has to do with the browser requesting a favico.ico icon that it uses to show in the URL bar (and some other places in the browser UI). If your server returns a 404 for favicon.ico, the browser will use a generic icon in its UI.



                If you want to make yourself a simple favico.ico, you can go here and it will help you generate one and then you can change the above route to:



                app.get('/favico.ico', (req, res) => 
                res.sendFile("myfavico.ico");
                );





                share|improve this answer























                  1












                  1








                  1






                  It's probably easiest to just make a route for favicon.ico in your server.



                  app.get('/favico.ico', (req, res) => 
                  res.sendStatus(404);
                  );


                  Of course, you could actually send a valid icon too if you wanted, but this will at least keep your Express server from showing an error.



                  FYI, this has nothing to do with the image-downloader. This has to do with the browser requesting a favico.ico icon that it uses to show in the URL bar (and some other places in the browser UI). If your server returns a 404 for favicon.ico, the browser will use a generic icon in its UI.



                  If you want to make yourself a simple favico.ico, you can go here and it will help you generate one and then you can change the above route to:



                  app.get('/favico.ico', (req, res) => 
                  res.sendFile("myfavico.ico");
                  );





                  share|improve this answer












                  It's probably easiest to just make a route for favicon.ico in your server.



                  app.get('/favico.ico', (req, res) => 
                  res.sendStatus(404);
                  );


                  Of course, you could actually send a valid icon too if you wanted, but this will at least keep your Express server from showing an error.



                  FYI, this has nothing to do with the image-downloader. This has to do with the browser requesting a favico.ico icon that it uses to show in the URL bar (and some other places in the browser UI). If your server returns a 404 for favicon.ico, the browser will use a generic icon in its UI.



                  If you want to make yourself a simple favico.ico, you can go here and it will help you generate one and then you can change the above route to:



                  app.get('/favico.ico', (req, res) => 
                  res.sendFile("myfavico.ico");
                  );






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 11 '18 at 22:27









                  jfriend00

                  428k53548595




                  428k53548595























                      0














                      Try using another package like request module. I believe it got this type of things handled.



                      var fs = require('fs'),
                      request = require('request');

                      var download = function(uri, filename, callback)
                      request.head(uri, function(err, res, body)
                      console.log('content-type:', res.headers['content-type']);
                      console.log('content-length:', res.headers['content-length']);

                      request(uri).pipe(fs.createWriteStream(filename)).on('close', callback);
                      );
                      ;

                      download('https://www.google.com/images/srpr/logo3w.png', 'google.png', function()
                      console.log('done');
                      );





                      share|improve this answer

























                        0














                        Try using another package like request module. I believe it got this type of things handled.



                        var fs = require('fs'),
                        request = require('request');

                        var download = function(uri, filename, callback)
                        request.head(uri, function(err, res, body)
                        console.log('content-type:', res.headers['content-type']);
                        console.log('content-length:', res.headers['content-length']);

                        request(uri).pipe(fs.createWriteStream(filename)).on('close', callback);
                        );
                        ;

                        download('https://www.google.com/images/srpr/logo3w.png', 'google.png', function()
                        console.log('done');
                        );





                        share|improve this answer























                          0












                          0








                          0






                          Try using another package like request module. I believe it got this type of things handled.



                          var fs = require('fs'),
                          request = require('request');

                          var download = function(uri, filename, callback)
                          request.head(uri, function(err, res, body)
                          console.log('content-type:', res.headers['content-type']);
                          console.log('content-length:', res.headers['content-length']);

                          request(uri).pipe(fs.createWriteStream(filename)).on('close', callback);
                          );
                          ;

                          download('https://www.google.com/images/srpr/logo3w.png', 'google.png', function()
                          console.log('done');
                          );





                          share|improve this answer












                          Try using another package like request module. I believe it got this type of things handled.



                          var fs = require('fs'),
                          request = require('request');

                          var download = function(uri, filename, callback)
                          request.head(uri, function(err, res, body)
                          console.log('content-type:', res.headers['content-type']);
                          console.log('content-length:', res.headers['content-length']);

                          request(uri).pipe(fs.createWriteStream(filename)).on('close', callback);
                          );
                          ;

                          download('https://www.google.com/images/srpr/logo3w.png', 'google.png', function()
                          console.log('done');
                          );






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 11 '18 at 22:27









                          Sinandro

                          14419




                          14419



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.





                              Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                              Please pay close attention to the following guidance:


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53253723%2fnode-express-favicon-ico-not-found-error%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Use pre created SQLite database for Android project in kotlin

                              Darth Vader #20

                              Ondo