Skip to content

No Content-Type when serving .ico files #13753

@tuyuritio

Description

@tuyuritio

Describe the bug

When I try to access favicon.ico via a browser, the browser prompts to download the file instead of displaying it.

Using curl, I found that the response has an empty Content-Type header.

This issue is not limited to favicon.ico—it happens with any .ico file.

Some third-party tools may rely on the Content-Type header to correctly identify and handle icon files. The absence of this header can cause issues or unexpected behavior in those cases.

Reproduction

  1. Create a minimal project using npx sv create.
  2. Download the icon from GitHub for testing.
  3. Place favicon.ico in the static directory.
  4. Add <link rel="shortcut icon" type="image/x-icon" href="%sveltekit.assets%/favicon.ico" /> to app.html.
  5. Run the project and execute curl -I http://localhost:5173/favicon.ico.
  6. The response returns an empty Content-Type.
  7. Rename favicon.ico to github.ico.
  8. Repeat steps 4 and 5. The result is the same.

Logs

`curl -I http://localhost:5173/favicon.ico`:


HTTP/1.1 200 OK
access-control-allow-origin: *
Content-Length: 6518
Content-Type:
Last-Modified: Tue, 29 Apr 2025 19:59:46 GMT
ETag: W/"6518-1745956786944"
Cache-Control: no-cache
...


`curl -I https://github.com/favicon.ico`:


HTTP/1.1 200 Connection established

HTTP/2 200
date: Tue, 29 Apr 2025 20:20:34 GMT
content-type: image/x-icon
last-modified: Tue, 29 Apr 2025 19:23:06 GMT
etag: W/"6811271a-1976"
expires: Fri, 27 Apr 2035 20:20:34 GMT
cache-control: max-age=315360000
vary: Accept-Encoding, Accept, X-Requested-With
server: github.com
...


`file favicon.ico`:


favicon.ico: MS Windows icon resource - 2 icons, 16x16, 32 bits/pixel, 32x32, 32 bits/pixel

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 AMD Ryzen 7 7840HS w/ Radeon 780M Graphics
    Memory: 15.50 GB / 31.28 GB
  Binaries:
    Node: 23.10.0 - C:\Program Files\nodejs\node.EXE
    npm: 11.2.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (134.0.3124.68)
  npmPackages:
    @sveltejs/adapter-auto: ^6.0.0 => 6.0.0
    @sveltejs/kit: ^2.20.7 => 2.20.7
    @sveltejs/vite-plugin-svelte: ^5.0.3 => 5.0.3
    svelte: ^5.28.2 => 5.28.2
    vite: ^6.3.3 => 6.3.3

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-decisionNot sure if we want to do this yet, also design work needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions