Skip to content

Serving images from endpoint routes no longer possible #1438

@drzax

Description

@drzax

Describe the bug

Prior to 1.0.0-next.82 it was possible to serve binary data from endpoint routes. Etag generation appears to cause an exception (str.charCodeAt is not a function) on subsequent versions (see #1136) and the fix in #1382, while preventing the exception also prevents serving binary data outside the narrow confines of a Content-Type: application/octet-stream http header.

To Reproduce

A minimum example which reproduces this issue (as provided in #1136 by @intrikate) is at https://github.com/intrikate/sveltekit-jpeg-endpoint-issue/blob/master/src/routes/index.jpg.js

Results:

Expected behaviour

The ability to serve binary data from endpoints without an exception or error. Obvious use case (as per the example above) is serving images, but more use cases are likely to exist.

Information about your SvelteKit Installation:

Diagnostics System: OS: macOS 10.15.7 CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 3.37 GB / 32.00 GB Shell: 5.0.11 - /usr/local/bin/bash Binaries: Node: 14.15.1 - ~/.nave/installed/default/bin/node Yarn: 1.22.10 - ~/.nave/installed/default/bin/yarn npm: 7.6.3 - ~/.nave/installed/default/bin/npm Browsers: Chrome: 92.0.4503.0 Edge: 90.0.818.56 Firefox: 88.0.1 Firefox Developer Edition: 79.0 Safari: 14.1 npmPackages: @sveltejs/kit: next => 1.0.0-next.104 svelte: ^3.34.0 => 3.38.2

Using Firefox and the node adapter, but that's not relevant to this issue.

Severity
This makes it impossible to serve images from an endpoint route. For my use case (a utility for generating static fallback imagery for @abcnews interactive content) that will make it impossible to sveltekit for the task.

So I'd rate the severity high.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions