Is this in regards when you are deploying your application, I believe that you need to set your Strapi URL ENV variable.
Check this article, here we use example where we deploy on Render. GitHub - derrickmehaffy/strapi-test-v4-render-deploy: Test deploying on render
Let me know if that helps. If you are having these issues when deploying, share you platform where you are deploying and your deployment setting to help us help you best.
I will also try to reproduce the error on the platform where you are trying to deploy.