# Getting assets in sveltekit -- should I use the new read tool from $app/server?

**URL:** <https://answers.netlify.com/t/getting-assets-in-sveltekit-should-i-use-the-new-read-tool-from-app-server/124556>\
**Category:** Support\
**Tags:** svelte\
**Created:** [August 23, 2024, 4:13am UTC](https://answers.netlify.com/t/getting-assets-in-sveltekit-should-i-use-the-new-read-tool-from-app-server/124556 "2024-08-23T04:13:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![seanluse41](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/seanluse41/32/63420_2.png) [@seanluse41](https://answers.netlify.com/u/seanluse41)\
**Post date:** [August 23, 2024, 4:13am UTC](https://answers.netlify.com/t/getting-assets-in-sveltekit-should-i-use-the-new-read-tool-from-app-server/124556/1 "2024-08-23T04:13:13Z")

</div>

Site: [https://master--seanbase.netlify.app/](https://master--seanbase.netlify.app/)

Hello Netlify team. I am testing out netlify services by building a small site.  
Things are going smoothly, however I have a problem with importing and using assets in a sveltekit +server.js endpoint.  
In this case, I am trying to import and use a font, and a png file to embed in a pdf file I generate.

There is some conflicting information online, but what I have tried is:

1. Placing assets in /static/
2. Placing assets in /src/lib
3. Placing assets in the endpoint folder  
And against those three, I have tried importing the files:

```auto
import NotoFont from './NotoSansJP-Regular.ttf';
import companyLogo from './logo-cropped.png'
import { read } from '$app/server';
    const font_data = await read(NotoFont).arrayBuffer();
    const customFont = await pdfDoc.embedFont(font_data)

```

The pdf generation worked on my local when simply placing assets in static, but from my research that changes when deploying to netlify. Makes sense.

When doing the above, currently I get the following error in my logs:

```auto
Aug 23, 09:34:38 AM: c194eb03 ERROR TypeError: Failed to parse URL from /_app/immutable/assets/NotoSansJP-Regular.BuIItb8O.ttfAug 23, 09:34:38 AM: c194eb03 ERROR at node:internal/deps/undici/undici:12618:11 {Aug 23, 09:34:38 AM: c194eb03 ERROR [cause]: TypeError [ERR_INVALID_URL]: Invalid URLAug 23, 09:34:38 AM: c194eb03 ERROR at new NodeError (node:internal/errors:405:5)Aug 23, 09:34:38 AM: c194eb03 ERROR at new URL (node:internal/url:676:13)Aug 23, 09:34:38 AM: c194eb03 ERROR at new Request (node:internal/deps/undici/undici:6108:25)Aug 23, 09:34:38 AM: c194eb03 ERROR at fetch (node:internal/deps/undici/undici:10396:25)Aug 23, 09:34:38 AM: c194eb03 ERROR at Object.fetch (node:internal/deps/undici/undici:12617:10)Aug 23, 09:34:38 AM: c194eb03 ERROR at fetch (node:internal/process/pre_execution:281:25)Aug 23, 09:34:38 AM: c194eb03 ERROR at GET (file:///var/task/.netlify/server/entries/endpoints/generate-receipt/_server.js:16:30)Aug 23, 09:34:38 AM: c194eb03 ERROR at async render_endpoint (file:///var/task/.netlify/server/index.js:180:20)Aug 23, 09:34:38 AM: c194eb03 ERROR at async resolve2 (file:///var/task/.netlify/server/index.js:2668:22)Aug 23, 09:34:38 AM: c194eb03 ERROR at async respond (file:///var/task/.netlify/server/index.js:2563:22) {Aug 23, 09:34:38 AM: c194eb03 ERROR input: '/_app/immutable/assets/NotoSansJP-Regular.BuIItb8O.ttf',Aug 23, 09:34:38 AM: c194eb03 ERROR code: 'ERR_INVALID_URL'Aug 23, 09:34:38 AM: c194eb03 ERROR }Aug 23, 09:34:38 AM: c194eb03 ERROR }

```

I am not sure why there is extra text in the filename, you can see that what I have as NotoSansJP-Regular.ttf has extra text in the filename in the logs. A hash perhaps?

One place I saw said to edit netlify.toml:

```auto
[functions]
  included_files = ["static/**"]

```

But this did not work either.  
Anyone have any experience in this regard?  
Thanks

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [August 25, 2024, 3:44pm UTC](https://answers.netlify.com/t/getting-assets-in-sveltekit-should-i-use-the-new-read-tool-from-app-server/124556/2 "2024-08-25T15:44:42Z")

</div>

Just to confirm, does this work if you try to prerender your site using SvelteKit’s static adapter?

---

<div class="post-metadata">

**Author:** ![bakerstreetirregular](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/bakerstreetirregular/32/55285_2.png) [@bakerstreetirregular](https://answers.netlify.com/u/bakerstreetirregular)\
**Post date:** [October 14, 2024, 11:38am UTC](https://answers.netlify.com/t/getting-assets-in-sveltekit-should-i-use-the-new-read-tool-from-app-server/124556/3 "2024-10-14T11:38:36Z")

</div>

Was this fixed? I am doing the same thing:

```auto
import satori from 'satori';
import { Resvg } from '@resvg/resvg-js';
import LibreSans from '$lib/fonts/LibreCaslonCondensed-Bold.ttf';
import { html as toReactNode } from 'satori-html';
import Card from '$lib/components/Primary/ShareCard.svelte';
import { read } from '$app/server';

const fontData = read(LibreSans).arrayBuffer();

const height = 630;
const width = 1200;

```

It works locally. But when deployed (and it does deploy, I can see logs in my Functions logs):

```auto
Oct 14, 04:55:29 PM: e1dac7cb ERROR [Error: ENOENT: no such file or directory, open '.netlify/server/_app/immutable/assets/LibreCaslonCondensed-Bold.I4TKy7ID.ttf'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '.netlify/server/_app/immutable/assets/LibreCaslonCondensed-Bold.I4TKy7ID.ttf'
}
Oct 14, 04:55:29 PM: e1dac7cb Duration: 347.77 ms	Memory Usage: 127 MB
Oct 14, 04:55:47 PM: 9d181a60 ERROR [Error: ENOENT: no such file or directory, open '.netlify/server/_app/immutable/assets/LibreCaslonCondensed-Bold.I4TKy7ID.ttf'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '.netlify/server/_app/immutable/assets/LibreCaslonCondensed-Bold.I4TKy7ID.ttf'
}

```

---

<div class="post-metadata">

**Author:** ![bakerstreetirregular](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/bakerstreetirregular/32/55285_2.png) [@bakerstreetirregular](https://answers.netlify.com/u/bakerstreetirregular)\
**Post date:** [October 19, 2024, 5:56am UTC](https://answers.netlify.com/t/getting-assets-in-sveltekit-should-i-use-the-new-read-tool-from-app-server/124556/4 "2024-10-19T05:56:02Z")

</div>

Any help with this? Still stuck so would be appreciated

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [October 19, 2024, 3:00pm UTC](https://answers.netlify.com/t/getting-assets-in-sveltekit-should-i-use-the-new-read-tool-from-app-server/124556/5 "2024-10-19T15:00:27Z")

</div>

You ignored my question and asked your own 🙂
