After uploading my adjusted gatsby-node.js file to Azure Static Web App I receive the following error:
error "gatsby-node.js" threw an error while running the createPages lifecycle:
Request failed with status code 500
Error:Request failed with status code 500
If I run the same definition in "gatsby develop" mode on my local machine everything works fine...
Here is my gatsby-node.js file:
const axios = require('axios');
const urls = [
`https://abc.azurestaticapps.net/data-api/rest/recipe`,
`https://abc.azurestaticapps.net/data-api/rest/recipekat`
]
const get = axios.all(urls.map((url) => axios.get(url)));
async function getRecipeData(){
const data = await get;
return data
}
exports.createPages = async({actions: {createPage}}) => {
const Data = await getRecipeData();
const allRecipes = Data[0].data.value;
const allRecipesKat = Data[1].data.value;
createPage({
path: `/recipes/`,
component: require.resolve('./src/templates/RecipesComp.js'),
context: { allRecipes }
});
createPage({
path: `/erstellen/`,
component: require.resolve('./src/templates/RecipesKatComp.js'),
context: { allRecipesKat }
});
}
After checking different websites I found no solution for this issue.
While trying with your code, I encountered an error fetching recipe data. Please check if the URL
https://abc.azurestaticapps.net/data-api/rest/recipeis accessible and if any authentication or permission configurations are required to access it.Note: If you are using a backend as an API, convert it into an Azure Function App (code).
src/components/RecipeList.js:
/src/pages/recipes.js:
I followed the configuration of Azure Static Web Apps. staticwebapp.config.json
Sample data from the backend in the URL:
git action status:
Static Web App Output: