Skip to content

Commit

Permalink
Make sure we use fetch on static route
Browse files Browse the repository at this point in the history
  • Loading branch information
razzeee committed Feb 9, 2025
1 parent dd2d55a commit ebfe9e4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions frontend/pages/login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useEffect } from "react"
import LoginProviders from "../../src/components/login/Providers"
import { useUserContext } from "../../src/context/user-info"
import { useTranslation } from "next-i18next"
import { getLoginMethodsAuthLoginGet } from "src/codegen"
import { fetchLoginProviders } from "src/fetchers"

export default function LoginPortal({ providers, locale }) {
const { t } = useTranslation()
Expand Down Expand Up @@ -45,12 +45,12 @@ export const getStaticProps: GetStaticProps = async ({
}: {
locale: string
}) => {
const providers = await getLoginMethodsAuthLoginGet()
const providers = await fetchLoginProviders()

return {
props: {
...(await serverSideTranslations(locale, ["common"])),
providers: providers.data,
providers: providers,
locale,
},
}
Expand Down
6 changes: 3 additions & 3 deletions frontend/pages/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import LoginGuard from "../src/components/login/LoginGuard"
import DeleteButton from "../src/components/user/DeleteButton"
import UserDetails from "../src/components/user/Details"
import { LoginProvider } from "../src/types/Login"
import { getLoginMethodsAuthLoginGet } from "src/codegen"
import { fetchLoginProviders } from "src/fetchers"

export default function Settings({
providers,
Expand Down Expand Up @@ -40,12 +40,12 @@ export const getStaticProps: GetStaticProps = async ({
}: {
locale: string
}) => {
const providers = await getLoginMethodsAuthLoginGet()
const providers = await fetchLoginProviders()

return {
props: {
...(await serverSideTranslations(locale, ["common"])),
providers: providers.data,
providers: providers,
},
revalidate: 900,
}
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/fetchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
APP_OF_THE_DAY_URL,
APPS_OF_THE_WEEK_URL,
MOBILE_APPS_URL,
LOGIN_PROVIDERS_URL,
} from "./env"
import { Summary } from "./types/Summary"
import { AppStats } from "./types/AppStats"
Expand All @@ -39,6 +40,11 @@ import {
import axios from "axios"
import { gameCategoryFilter } from "./types/Category"

export async function fetchLoginProviders() {
const res = await fetch(LOGIN_PROVIDERS_URL)
return await res.json()
}

export async function fetchAppstream(
appId: string,
locale: string,
Expand Down

0 comments on commit ebfe9e4

Please sign in to comment.