contentstack / app-sdk

The Contentstack App SDK allows you to customize your applications.
MIT License
1 stars 3 forks source link

Cannot upload asset using Asset.uploadAsset() method #105

Closed apankov closed 2 months ago

apankov commented 9 months ago

Hello. I'm trying to upload an asset using the UploadAssetModal component from the @contentstack/venus-components library, and the Asset.uploadAsset() method from @contentstack/app-sdk. The Asset.uploadAsset method returns the error "No handler found for post message: stackOptionsQuery from http://localhost:3000 in ...", full error message is provided below.

The simplified setup is as follows.

const uploadAssetProps: any = {
 sdk,
 onSubmit,
 only: "code",
 multiple: false,
 upload: ({ files, options }: any) => {
  return sdk?.stack.Asset.uploadAsset(files, options)
   .then((res) => console.log('Upload result', res))
   .catch((err) => console.log('Upload error' ,err));
};
<Button onClick={() => openUploadAssetModal(uploadAssetProps)}>
 Upload Asset
</Button>

Error message:

Upload error Error: No handler found for post message: stackOptionsQuery from http://localhost:3000 in https://app.contentstack.com/
    at eval (eval at e.exports (vendor.bundle.js:1:1), <anonymous>:2000:23)
    at ZalgoPromise.try (eval at e.exports (vendor.bundle.js:1:1), <anonymous>:1303:29)
    at exports.RECEIVE_MESSAGE_TYPES._RECEIVE_MESSAGE_TYPE.<computed> [as postrobot_message_request] (eval at e.exports (vendor.bundle.js:1:1), <anonymous>:1998:34)
    at receiveMessage (eval at e.exports (vendor.bundle.js:1:1), <anonymous>:1896:57)
    at messageListener (eval at e.exports (vendor.bundle.js:1:1), <anonymous>:1916:9)
    at rt.<computed> [as postrobot_message_response] (index.js:2:23116)
    at ft (index.js:2:24840)
    at dt (index.js:2:24896)

Debug output by @contentstack/app-sdk:

[post-robot] fullpage :: app.contentstack.com/ 

     #send response :: stackOptionsQuery :: http://localhost:3000 

{
  ack: "error",
  code: undefined,
  data: undefined,
  domain: "http://localhost:3000",
  error: "No handler found for post message: stackOptionsQuery from http://localhost:3000 in https://app.contentstack.com/\n at eval (eval at e.exports (https://app.contentstack.com/vendor.bundle.js?v=1.2.4:1:1), <anonymous>:2000:23)\n at ZalgoPromise.try (eval at e.exports (https://app.contentstack.com/vendor.bundle.js?v=1.2.4:1:1), <anonymous>:1303:29)\n at exports.RECEIVE_MESSAGE_TYPES._RECEIVE_MESSAGE_TYPE.<computed> [as postrobot_message_request] (eval at e.exports (https://app.contentstack.com/vendor.bundle.js?v=1.2.4:1:1), <anonymous>:1998:34)\n at receiveMessage (eval at e.exports (https://app.contentstack.com/vendor.bundle.js?v=1.2.4:1:1), <anonymous>:1896:57)\n at messageListener (eval at e.exports (https://app.contentstack.com/vendor.bundle.js?v=1.2.4:1:1), <anonymous>:1916:9)"
  hash: "stackOptionsQuery_bb3c7fbad8",
  id: "58ee04db3d",
  name: "stackOptionsQuery",
  sourceDomain: "https://app.contentstack.com",
  target: undefined,
  type: "postrobot_message_response",
  windowType: "fullpage"
}
abhishek305 commented 2 months ago

Hi @apankov, Could you please verify this again we have addressed this issue. Also, could you upgrade your appsdk version to latest? Please re-open if the issue persists.