SvelteKit with adapter-static throws an error > 404 at <img> path in markup

Viewed 1035

src attribute in img uses absolute path:

<script>
    let herbURL = '/media/events/odessa/gerb.png',
</script>

<img src={thumbURL} />

And while npm run dev works fine, npm run build thwrows en error:

> 404 /media/events/odessa/gerb.png (linked from /)
Error: 404

But when I move media folder in buildfolder — build as well work ok.

The problem is only with paths for src attribute in img tags: adapter-static for some reason couldn't find them (thoug he does see images in background url's in css).

How to fix this?

1 Answers

The solution is to put assets not into the root, but into the static folder! So media folder for example should be in static/media.

Related