Skip to content

Commit 433538b

Browse files
authored
fix(storage): remove client-side signed URL render endpoint normalization (#2249)
1 parent f9da9ee commit 433538b

2 files changed

Lines changed: 6 additions & 14 deletions

File tree

packages/core/storage-js/src/packages/StorageFileApi.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -667,18 +667,10 @@ export default class StorageFileApi extends BaseApiClient<StorageError> {
667667
if (options?.cacheNonce != null) query.set('cacheNonce', String(options.cacheNonce))
668668
const queryString = query.toString()
669669

670-
// When transforms are requested the signed URL must use the render endpoint.
671-
// Some storage-api versions return /object/sign/ even for transform requests,
672-
// so we normalise the path on the client side.
673-
const returnedPath =
674-
hasTransform && data.signedURL.includes('/object/sign/')
675-
? data.signedURL.replace('/object/sign/', '/render/image/sign/')
676-
: data.signedURL
677-
678-
// `returnedPath` contains a `token` query parameter, so append extra params with `&` only
679-
// when we actually have something to add.
670+
// `data.signedURL` contains a `token` query parameter, so append extra params with `&`
671+
// only when we actually have something to add.
680672
const signedUrl = encodeURI(
681-
`${this.url}${returnedPath}${queryString ? `&${queryString}` : ''}`
673+
`${this.url}${data.signedURL}${queryString ? `&${queryString}` : ''}`
682674
)
683675

684676
return { signedUrl }

packages/core/storage-js/test/storageFileApi.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,18 @@ describe('Object API', () => {
119119
})
120120

121121
expect(res.error).toBeNull()
122-
expect(res.data?.signedUrl).toContain(`${URL}/render/image/sign/${bucketName}/${uploadPath}`)
122+
expect(res.data?.signedUrl).toContain(`/${bucketName}/${uploadPath}`)
123+
expect(res.data?.signedUrl).toContain('token=')
123124
})
124125

125-
test('sign url with empty transform object does not use render endpoint', async () => {
126+
test('sign url with empty transform object uses object endpoint', async () => {
126127
await storage.from(bucketName).upload(uploadPath, file)
127128
const res = await storage.from(bucketName).createSignedUrl(uploadPath, 2000, {
128129
transform: {},
129130
})
130131

131132
expect(res.error).toBeNull()
132133
expect(res.data?.signedUrl).toContain(`${URL}/object/sign/${bucketName}/${uploadPath}`)
133-
expect(res.data?.signedUrl).not.toContain('/render/image/sign/')
134134
})
135135

136136
test('sign url with custom filename for download', async () => {

0 commit comments

Comments
 (0)