-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Can't fetch assets using Kits fetch
and relative path
#12081
Comments
I Think export const GET: RequestHandler = async ({ fetch , url, platform }) => { It works for me |
@Rishab49 export const GET = async (event) => {
const sk_fetch = event.fetch;
...
} I renamed it to clearly differentiate global fetch and the one from SvelteKit here
Did you test it with Cloudflare adapter & wrangler? If yes, could you share a minimal setup? That would really help me. |
oh I forgot to test it with wrangler(apologies), its a bug |
6 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
According to the documentation (here and here), kits
fetch
should be able to handle relative paths on the server.This works in development, but not in production (I've tested Cloudflare and node adapters).
If I do this:
The response is always this exact 404 (as far as I can tell):
kit/packages/kit/src/runtime/server/respond.js
Lines 118 to 120 in df6641a
We end up here, because the
server_fetch
doesn't recognise this path as an asset.Following check seams to be the problem:
kit/packages/kit/src/runtime/server/fetch.js
Lines 84 to 87 in df6641a
as it doesn't check
manifest._.server_assets
I've created an exhaustive reproduction that shows differences between sk/global fetch and absolute/relative path here:
https://github.com/mastermakrela/sveltekit-relative-assets-fetch-bug
Solutions considered
Use
read
read
is sync and Cloudflaresenv.ASSETS.fetch
isn'tChange
is_asset
check in Kit toChange
is_static_asset
check in Cloudflare adapter to:Use global fetch
Semantically async
read
+ Cloudflare implementation, would be most satisfying, but it's probably leas viable, because of breaking change.But independent of read, not being able to fetch assets using relative path on server seams to be a bug, that should be fixed (or if not at least a warning in dev mode would be nice).
Reproduction
https://github.com/mastermakrela/sveltekit-relative-assets-fetch-bug
Logs
No response
System Info
Severity
serious, but I can work around it
Additional Information
No response
The text was updated successfully, but these errors were encountered: