App Bridge v4 prevent installing the app

I’m trying to migrate my Shopify app (in Next.js) to App Bridge v4.

I place the HTML tags in _document.js and they succesfully load the script. Unfortunately, I can’t install the app while the script is present. It displays 404 page.


        

Once I remove the script, I am able to install the app, but of course the auth doesn’t work. Once the app is installed and I add the script back, the auth and the app work.

So basicaly the script tag breaks the app Installation part.

We had same issue with Docker when deploying and fix was to add api key directly to content=“KEY HERE”