Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Favicon.ico Not Found #3525

Closed
lemmon opened this issue Jan 24, 2022 · 3 comments · Fixed by #3559
Closed

Favicon.ico Not Found #3525

lemmon opened this issue Jan 24, 2022 · 3 comments · Fixed by #3559
Labels
bug Something isn't working
Milestone

Comments

@lemmon
Copy link

lemmon commented Jan 24, 2022

Describe the bug

Starting version 231 svelte-kit is no longer able to display static asset favicon.ico. I have previously described the issue here: #3393 (comment):

I have [probably] the same issue, starting v 231. However, I haven't applied any special settings for kit.paths nor the adapter. Everything is set to default.

The only affected file is favicon.ico.

HTTP/1.1 404 Not Found
Content-Length: 9

But the very same file renamed to favicon2.ico works just fine:

HTTP/1.1 200 OK
Content-Length: 61

Every other file seems to be working just fine.

Reproduction

https://github.com/lemmon/svelte-kit-favicon-issue

Try to load http://localhost:3000/favicon.ico -> 404 Not Found

Logs

No response

System Info

System:
    OS: macOS 11.5.2
    CPU: (4) x64 Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
    Memory: 407.90 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.17.1 - /usr/local/bin/node
    npm: 8.3.1 - /usr/local/bin/npm
  Browsers:
    Brave Browser: 88.1.19.86
    Chrome: 97.0.4692.99
    Firefox: 96.0.1
    Safari: 15.0
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.14 
    @sveltejs/kit: next => 1.0.0-next.240 
    svelte: ^3.44.0 => 3.46.2

Severity

annoyance

Additional Information

No response

@benmccann benmccann added this to the 1.0 milestone Jan 24, 2022
@benmccann benmccann added the bug Something isn't working label Jan 24, 2022
@vfilatov
Copy link

vfilatov commented Jan 24, 2022

Not sure if that line is needed.

The workaround:

diff --git a/packages/kit/src/core/dev/plugin.js b/packages/kit/src/core/dev/plugin.js
index f8116132..90ec560c 100644
--- a/packages/kit/src/core/dev/plugin.js
+++ b/packages/kit/src/core/dev/plugin.js
@@ -141,7 +141,7 @@ export async function create_plugin(config, cwd) {
                                vite.middlewares.use(async (req, res) => {
                                        try {
                                                if (!req.url || !req.method) throw new Error('Incomplete request');
-                                               if (req.url === '/favicon.ico') return not_found(res);
+                                               //if (req.url === '/favicon.ico') return not_found(res);
 
                                                const base = `${vite.config.server.https ? 'https' : 'http'}://${req.headers.host}`;

@tfpgh
Copy link

tfpgh commented Jan 25, 2022

Not sure if that line is needed.

The workaround:

diff --git a/packages/kit/src/core/dev/plugin.js b/packages/kit/src/core/dev/plugin.js
index f8116132..90ec560c 100644
--- a/packages/kit/src/core/dev/plugin.js
+++ b/packages/kit/src/core/dev/plugin.js
@@ -141,7 +141,7 @@ export async function create_plugin(config, cwd) {
                                vite.middlewares.use(async (req, res) => {
                                        try {
                                                if (!req.url || !req.method) throw new Error('Incomplete request');
-                                               if (req.url === '/favicon.ico') return not_found(res);
+                                               //if (req.url === '/favicon.ico') return not_found(res);
 
                                                const base = `${vite.config.server.https ? 'https' : 'http'}://${req.headers.host}`;

Commit that added it. Looks like a refactor though, so might have been introduced earlier.

@nhe23
Copy link
Contributor

nhe23 commented Jan 26, 2022

It seems like this line has always been there ... I checked the git logs all the way back to march of last year. I can't think of a good reason of why this line is needed. I don't see why SvelteKit should not support .ico files for the favicon as they are broadly used. Also the current behaviour is inconsistent as 404 is only returned in dev mode. I'll remove it and create a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants