I am building a web app with Gatsby and are having trouble figuring out how to fetch data from the deployed Strapi-app. Gatsby is deployed to Netlify, Strapi deployed to Heroku. (I have no trouble fetching data when running both projects locally)
I appreciate all the help and useful advice!
EDIT: Found one solution to this problem. In gatsby-config.js -> gatsby-source-strapi; set apiURL = "process.env.API_URL || 'http://localhost:1337'", and made a new file called ".env.development" in the root folder and typed in "API_URL='your-heroku-app'"
I am sure there exist a similar solution to use when it is not in development-mode.
We explain how to deploy both Strapi on Heroku and Gatsby on Netlify in this tutorial: https://strapi.io/blog/building-a-static-website-using-gatsby-and-strapi#11deploygatsbytonetlify
I hope it will provide the answer to your question :)
Cheers!