Skip to content

Commit

Permalink
Add safeguard to mediaUploadMiddleware (WordPress#64843)
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy authored and bph committed Aug 31, 2024
1 parent aec4bc0 commit 06129f5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/api-fetch/src/middlewares/media-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ const mediaUploadMiddleware = ( options, next ) => {

return next( { ...options, parse: false } )
.catch( ( response ) => {
// `response` could actually be an error thrown by `defaultFetchHandler`.
if ( ! response.headers ) {
return Promise.reject( response );
}

const attachmentId = response.headers.get(
'x-wp-upload-attachment-id'
);
Expand Down

0 comments on commit 06129f5

Please sign in to comment.