feat: add image proxy route to serve Directus assets with auth token

This commit is contained in:
achmad
2026-05-29 01:31:54 +07:00
parent 69a5f5f9f5
commit 8f725d5e26
3 changed files with 40 additions and 4 deletions
+3 -2
View File
@@ -60,10 +60,10 @@ describe('getArticleBySlug', () => {
})
describe('getAssetUrl', () => {
it('constructs a Directus asset URL from a file UUID', async () => {
it('constructs a proxied asset URL from a file UUID', async () => {
const { getAssetUrl } = await import('@/lib/directus')
const url = getAssetUrl('abc-123-uuid')
expect(url).toBe('https://cms.achmad.dev/assets/abc-123-uuid')
expect(url).toBe('/api/image/abc-123-uuid')
})
it('appends width and quality query params', async () => {
@@ -71,5 +71,6 @@ describe('getAssetUrl', () => {
const url = getAssetUrl('abc-123-uuid', { width: 800, quality: 80 })
expect(url).toContain('width=800')
expect(url).toContain('quality=80')
expect(url).toContain('/api/image/')
})
})