Skip to content

Commit f35d10a

Browse files
committed
fix: internal vs external metadata headers
1 parent 0327476 commit f35d10a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class Client {
5959
}
6060

6161
if (encodedMetadata) {
62-
headers[METADATA_HEADER_EXTERNAL] = encodedMetadata
62+
headers[METADATA_HEADER_INTERNAL] = encodedMetadata
6363
}
6464

6565
const path = key ? `/${this.siteID}/${storeName}/${key}` : `/${this.siteID}/${storeName}`

src/metadata.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@ export const getMetadataFromResponse = (response: Response) => {
3939
return {}
4040
}
4141

42+
// If metadata is coming from the API, it will be under the external header.
43+
// If it's coming from the edge, it will be under the internal header.
44+
const value = response.headers.get(METADATA_HEADER_INTERNAL) || response.headers.get(METADATA_HEADER_EXTERNAL)
45+
4246
try {
43-
return decodeMetadata(response.headers.get(METADATA_HEADER_INTERNAL))
47+
return decodeMetadata(value)
4448
} catch {
4549
throw new Error(
4650
'An internal error occurred while trying to retrieve the metadata for an entry. Please try updating to the latest version of the Netlify Blobs client.',

0 commit comments

Comments
 (0)