feat: add image proxy route to serve Directus assets with auth token
This commit is contained in:
@@ -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/')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user