Confluence rest api dynamic macro loading error for tabs

Currently I`m working on a project using confluence rest api to get docs from our confluence server and render on our own website, but there seems to be some problem whenever js dynamically loading macro and functions.

On our website, we have corresponding html,css and js file loaded from rest api.

  1. Js files are loaded synchronously
  2. html with styled_view in then loaded

Finally we have a somewhat working rendered page for most of our docs except for those that have macros, especially the tab component.

Like above example, the resources loaded properly while the exec call always shows 400 bad request.
The content below the tabpanes will always be “Failed to execute macro: Bad Request”