Patrik
Patrik
Explore posts from servers
NNuxt
Created by Patrik on 7/20/2024 in #❓・help
Render images from api via fs
hello im using fs storage with folder in root directory (/images) also have endpoint to render images
// /server/api/test.ts
setHeader(event, 'content-type', 'image/jpeg')
return await useStorage('images').getItemRaw("123.jpg")
// /server/api/test.ts
setHeader(event, 'content-type', 'image/jpeg')
return await useStorage('images').getItemRaw("123.jpg")
i can render it inside template and it works
// /app.vue
<NuxtImg src="http://localhost:3000/api/test?image=123.jpg"/>
// /app.vue
<NuxtImg src="http://localhost:3000/api/test?image=123.jpg"/>
but i always need to set http(s) path to host where i reach that: like 127.0.0.1:3000 or 192.168.1.100:3000 or other ip web server i think u got me the question is what can i do to avoid hardcoding path and make dynamic i cant make a repro for some reason but here is repo https://github.com/melasculla/first-nuxt-crud/tree/image-test
2 replies