feat: add image proxy route to serve Directus assets with auth token
This commit is contained in:
+2
-2
@@ -160,9 +160,9 @@ export function getAssetUrl(
|
||||
fileId: string,
|
||||
params?: { width?: number; height?: number; quality?: number },
|
||||
): string {
|
||||
const url = new URL(`/assets/${fileId}`, process.env.DIRECTUS_URL!)
|
||||
const url = new URL(`/api/image/${fileId}`, 'http://localhost')
|
||||
if (params?.width) url.searchParams.set('width', String(params.width))
|
||||
if (params?.height) url.searchParams.set('height', String(params.height))
|
||||
if (params?.quality) url.searchParams.set('quality', String(params.quality))
|
||||
return url.toString()
|
||||
return url.pathname + url.search
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user