Intevel / nuxt-directus

🐰 Easily integrate Directus to your Nuxt application.
https://nuxt-directus.de/
MIT License
269 stars 49 forks source link

getThumbnail - TypeError: Failed to construct 'URL': Invalid URL #119

Closed NeekoDev closed 1 year ago

NeekoDev commented 1 year ago

Version

nuxt-directus : 5.0.1 nuxt : 3.2.3

Steps to reproduce

Simply :

<img :src="img(fileId)">
const fileId = "b40911b1-e4e0-4fc0-a080-21b85ed921ff";
const { getFiles, getThumbnail: img } = useDirectusFiles();

What is Expected?

Show image.

What is actually happening?

Uncaught (in promise) TypeError: Failed to construct 'URL': Invalid URL
    at Proxy.getThumbnail (useDirectusFiles.mjs?v=4eb507e2:24:17)

In :

const getThumbnail = (fileId, options) => {
    const url = new URL(`${directusUrl}assets/${fileId}`); <---

Another question, how to use getFiles to v-bind= file like video/mp4 from Directus ?

Thanks ! :)

paulvonber commented 1 year ago

Looks like a bit related to my issue, I have the same error if I'm not explicitly adding directus url to the config, in production it doesn't catch DIRECTUS_URL env variable, but works in dev mode.

Intevel commented 1 year ago

@paulvonber Thanks. I create a new issue

Intevel commented 1 year ago

Looks like a bit related to my issue, I have the same error if I'm not explicitly adding directus url to the config, in production it doesn't catch DIRECTUS_URL env variable, but works in dev mode.

Fixed with 5.1.3 👯