How can I make an API call from the payment page?

Hi

I am trying to customise payment page by loading a script in head tag that will make some API call and alter some HTML. While this approach works on all pages with exception of payment pages. There’s CSP headers which are set to observe and report. But the thing it as soon as the line which makes API call is executed, the script entirely stops, no exception is raised and all falls silent. I am not sure what’s happening. All the resources are served via HTTPS using Ngrok, js script as well as API endpoints.

Has anyone run into similar situation. I am on Shopify Plus plan so editing checkout.liquid is possible.

Thanks You