0

I deployed an App to AWS-Amplify, when building and serving it locally, it leverages ISR functionality, but after deployment It does not work anymore. I looked into the dynamoDb for the records, and there is new data, also the revalidate option is set to revalidate: 60, but still the pages does not get recreated. I also don't seem to find any lambda functions for this app.

If there are resources I can provide to clarify the problem, let me know.

Thank you in advance.

This is my function on the only page which uses SSG with ISR.

export const getStaticProps: GetStaticProps<{
  menu_data: string
}> = async () => {
  const days = [
    "Montag",
    "Dienstag",
    "Mittwoch",
    "Donnerstag",
    "Freitag",
    "Samstag",
    "Sonntag",
  ]

  const menuData: { menu_data: Array<Array<IMenuItem>> } = {
    menu_data: [[], [], [], [], [], [], []],
  }

  try {
    for (let i = 0; i < 7; i++) {
      const fetchedDayMenu = (await API.graphql(
        graphqlOperation(dayMenuByTitle, { title: days[i] })
      )) as { data: DayMenuByTitleQuery }

      const dayMenuItem = fetchedDayMenu.data.dayMenuByTitle?.items[0]
      let dayMenuId = ""
      if (dayMenuItem?.id) {
        dayMenuId = dayMenuItem.id
      }

      if (dayMenuId !== "") {
        const response = (await API.graphql(
          graphqlOperation(dishesByDayMenuID, { dayMenuID: dayMenuId })
        )) as { data: DishesByDayMenuIDQuery }

        if (response.data && response.data.dishesByDayMenuID) {
          const fetchedDishes = response.data.dishesByDayMenuID.items

          for (const index in fetchedDishes) {
            const dish = fetchedDishes[index]
            if (dish) {
              const parsedDish = {
                dish_text: dish.dish_text,
                price: dish.price,
                isVegetarian: dish.isVegetarian,
              }

              menuData.menu_data[i].push(parsedDish)
            }
          }
        }
      }
    }
  } catch (e) {
    console.log(e)
  }

  return {
    props: { menu_data: JSON.stringify(menuData) },
    revalidate: 60,
  }
}

package.json

{
  "name": "app-name",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build && next export ",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@aws-amplify/ui-react": "^5.0.4",
    "@types/formidable": "^2.0.6",
    "@types/mime": "^3.0.1",
    "@types/node": "18.15.11",
    "@types/react": "18.0.31",
    "@types/react-dom": "18.0.11",
    "amplify": "^0.0.11",
    "aws-amplify": "^5.3.3",
    "eslint": "8.37.0",
    "eslint-config-next": "13.2.4",
    "framer-motion": "^10.12.17",
    "mime": "^3.0.0",
    "next": "13.2.4",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-icons": "^4.8.0",
    "sharp": "^0.32.1",
    "swr": "^2.1.5",
    "typescript": "5.0.2"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^5.57.1",
    "eslint-config-prettier": "^8.8.0",
    "husky": "^8.0.3",
    "lint-staged": "^13.2.1",
    "prettier": "^2.8.7",
    "sass": "^1.62.0"
  }
}

I did deploy it manual and with CI/CD via GitHub, I also removed the app completely and deployed it again several times.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
DrGregoryHouse
  • 510
  • 5
  • 12

0 Answers0