node.jsgithub-actionsgatsbyazure-static-web-appjamstack

Azure Static Web App with Gatsby not calling 3rd party external API (405 Status)


To illustrate the problem, please see the differences in request headers between app running on localhost and on Azure Static Web App service.

On Localhost:

enter image description here

On Azure Static Web Apps Service:

enter image description here

Other Info

The environment variables, locally, are held in a '.env' file. On Azure these were held in GitHub secrets and referenced under the 'env:' section of the Actions workflow. There is another API specified in the same way and that works fine, but the working API is called at build time, while the problematic one is called at runtime.

So, to see if it will resolve this, for the runtime environment variables, I now specify these under Azure Application Settings. This still has not resolved the issue


Solution

  • This specific issue was resolved by ensuring that browser accessed environment variables start with 'GATSBY_' as mentioned here: https://www.gatsbyjs.com/docs/how-to/local-development/environment-variables/#accessing-environment-variables-in-the-browser