koalazak/rest980

Favicon support

Closed this issue · 1 comments

Thanks for making rest980! After trying the /map interface I have a small suggestion.

Loading the interface will cause a browser to send a request to /favicon.ico to get the site's icon that's displayed on the tab or in the bookmarks. This request causes a long stack trace to be logged in the console, and logs errors to the browser's developer console too:

GET /favicon.ico 404 0.450 ms - 2558
Error: Endpoint not found.
    at /Users/my-username/src/rest980/app.js:62:13
    at Layer.handle [as handle_request] (/Users/my-username/src/rest980/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/Users/my-username/src/rest980/node_modules/express/lib/router/index.js:317:13)
    at /Users/my-username/src/rest980/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/Users/my-username/src/rest980/node_modules/express/lib/router/index.js:335:12)
    at next (/Users/my-username/src/rest980/node_modules/express/lib/router/index.js:275:10)
    at /Users/my-username/src/rest980/node_modules/express/lib/router/index.js:635:15
[...] (24 lines total)

rest980 could either serve an actual image file, or avoid the request entirely by adding an inline image using a <link> tag with base64-encoded content. With an SVG icon this can be very concise, e.g. with:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y=".9em" font-size="90">🤖</text></svg>

you could encode this ^ full string and add this single line to your <head> section:

<link rel="shortcut icon" href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj48dGV4dCB5PSIuOWVtIiBmb250LXNpemU9IjkwIj7wn6SWPC90ZXh0Pjwvc3ZnPg==">

added! thank you!