framework icon indicating copy to clipboard operation
framework copied to clipboard

fix(nuxt): add default 1px blank favicon gif

Open danielroe opened this issue 3 years ago • 4 comments

🔗 Linked issue

❓ Type of change

  • [ ] 📖 Documentation (updates to the documentation or readme)
  • [x] 🐞 Bug fix (a non-breaking change that fixes an issue)
  • [ ] 👌 Enhancement (improving an existing functionality like performance)
  • [ ] ✨ New feature (a non-breaking change that adds functionality)
  • [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

This adds a tiny favicon.ico to the default nitro stack to prevent the annoying router error message:

[Vue Router warn]: No match found for location with path "/favicon.ico"

It allows overriding by the user creating ~/public/favicon.ico.

Note: we have serve-placeholder support in nitro but don't enable it for / (probably rightly). Without this PR (even if we enabled serve-placeholder) we'd still be hitting the Nitro runtime on every request.

📝 Checklist

  • [ ] I have linked an issue or discussion.
  • [ ] I have updated the documentation accordingly.

danielroe avatar Jun 03 '22 10:06 danielroe

Deploy Preview for nuxt3-docs canceled.

Name Link
Latest commit ae8d90bf10eecea3f089a2f443ec5648ea2421da
Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/62c368e71bd1a00008ce65e8

netlify[bot] avatar Jun 03 '22 10:06 netlify[bot]

I believe we are adding fallback (before renderer with known extensions) as a configurable feature of Nitro. This way we can handle other edge cases such as sw.js and other 404 public assets. Linked issue: https://github.com/unjs/nitro/issues/94

pi0 avatar Jun 03 '22 13:06 pi0

I'm aware of the linked issue, but thought it would be still worth adding this.

The merit in adding the default favicon is that it will be added to public folder when built and thereby skip hitting the nitro runtime for deploy targets with a CDN.

danielroe avatar Jun 03 '22 14:06 danielroe

I believe this is worth adding as well since it is already a nice fix and feature ready to go and can be refactor with a nitro update 😊

atinux avatar Jun 19 '22 22:06 atinux

With new defineRenderHandler in nitro (https://github.com/unjs/nitro/pull/395), we catch favicon.ico 404 (easily improved later for another kind of placeholders).

I also like the idea of generating a static asset to avoid hitting lambda at all but I think we can use prerender and a new dynamic render handler to implement directly in nitro as another enhancement because this way we can allow custom dynamic handlers that generate the asset on demand.

pi0 avatar Aug 11 '22 21:08 pi0