-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
SvelteKit loads favicon every page request and messes up the request #3748
Comments
Same issue doing my head in all day, more or less identical to yours. Can't always reproduce it though, seems to happen randomly when opening a certain kind of content. I've tried a few things, the latest being to remove |
Exactly, I have noticed the bug is not happening all the time. Which makes it even more strange. |
I can confirm that "silencing" the bug by removal of %svelte.assets% from this line: link rel="icon" href="%svelte.assets%/favicon.png" in app.html.proposed by rumack helped for the time being. |
For info, I stumbled on this (same/similar) closed issue where you'll maybe find a better explanation and solution: #3582 (comment). See this too: #3234 (comment) |
There is also same issue discussed on StackOverflow SvelteKit loads favicon every page request |
I think there are two problems here:
@kvetoslavnovak can you please update the issue accordingly with this numbered list if you agree? It should be noted that even with old versions of SvelteKit (of December or even earlier) the favicon was requested at each navigation. |
This comment was marked as duplicate.
This comment was marked as duplicate.
Does setting the |
Nope. I cannot create a repro now (due to lack of time). |
Sorry, just seeing these last exchanges now. I went back into the three Sveltekit apps where I was getting this error and reinserted |
I'm on I can fix it using a static Using |
Sorry, I spoke too soon. Error not fixed. I've had to remove the |
Again, we need a minimal repro if we're to investigate this. "See the structure in the picture above" does not count — see https://github.com/sveltejs/kit/blob/master/.github/ISSUE_TEMPLATE/bug_report.yml |
@Rich-Harris Thank you for all the work you've put into the svelte ecosystem. I'm sure I can speak for many of us in the community when I say that we are very grateful for the toolkit you've been building. This issue has been plaguing me 😂! I've created a minimal reproduction here: https://github.com/Vehmloewff/sveltekit-favicon-request My Workaround for (const param in event.params) {
const value = event.params[param];
if (value === 'favicon.png')
return new Response('Ugg! One of those extra requests again!', { status: 400 });
} |
Here's what I see when I run that reproduction locally — it works correctly, whether I'm doing a server-side or client-side navigation: Aside: this isn't the point of this issue, but in the repro README you ask
The reason is that you're calling |
I have a similar "problem" (quotes because it does not really break anything but my client wants to get rid of errors in the console). I noticed that only Chrome/Chromium loads the favicon on each navigation, on Firefox it is fine. The issue (console errors) happens when the url generated by Again this does not break anything but is only annoying. |
@Rich-Harris try to reproduce it in stackblitz with no fruits. locally it happens if this is your first time doing
the =======[7:53:11]=======
[id] === tt3438640]
=======[7:53:11]=======
[id] === favicon.png]
res => error: Incorrect IMDb ID.
=============== considerations: this seems like a good explanation @fehnomenal #3748 (comment)
|
Doesn't happen on Firefox. |
I'm currently working on a fix, but I need some clarification on why does sveltekit use relative urls for assets: kit/packages/kit/src/runtime/server/page/render.js Lines 295 to 301 in 5eb7652
Here is what I suggest instead: const assets = options.paths.assets || options.paths.base;
const html = await resolve_opts.transformPage({
html: options.template({ head, body, assets, nonce: /** @type {string} */ (csp.nonce) })
}); I you still have this issue, could you please try patching Edit: it looks like |
…gating (#5583) * make link hrefs absolute - fixes #3748 * ugh stfu eslint you miserable funsucker * update test * Create stupid-dolls-fly.md * Update packages/kit/src/runtime/client/client.js Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> * Update packages/kit/test/apps/basics/test/test.js Co-authored-by: Rich Harris <richard.a.harris@gmail.com> * see if this makes different tests fail on safari * Revert "see if this makes different tests fail on safari" This reverts commit 91049b7. * i hate safari with the fire of a thousand suns * Update .changeset/stupid-dolls-fly.md * Update packages/kit/src/runtime/client/client.js * Update packages/kit/src/runtime/client/client.js * ugh this is easier than fighting with typescript Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Just to add - for anyone else using the bun runtime that is still seeing this issue; I tried many things to resolve this locally but ultimately had to switch back to node. As soon as I swapped |
Describe the bug
I think there are two problems here:
I have an API in SvelteKit structured as this

For some very strange reason SvelteKit tries to load favicon with every request in a very weird way.

Moreover when I check the params of the request with values lang: 'en' and searched: '32015L2366' I see that there were two requests:
The first request:
Console logged params are:
The second request {correct one) is:
Console logged params are:
Looks like a ghost in the shell.
Reproduction
See the structure in the picture above.
Logs
No response
System Info
Pop!_OS 21.10 , Browser info can be seen hereabove.
Severity
serious, but I can work around it
Additional Information
No response
The text was updated successfully, but these errors were encountered: