Skip to content

Commit a47f00c

Browse files
authored
Merge pull request #569 from PotLock/revert-568-staging
Revert "Staging to prod"
2 parents 821373e + fe8216f commit a47f00c

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/pages/campaign/[campaignId]/index.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ReactElement, useMemo } from "react";
22

3-
import type { GetStaticPaths, GetStaticProps } from "next";
3+
import type { GetServerSideProps } from "next";
44
import { useRouter } from "next/router";
55

66
import { INDEXER_API_ENDPOINT_URL } from "@/common/_config";
@@ -51,13 +51,12 @@ CampaignPage.getLayout = function getLayout(page: ReactElement) {
5151
return <CampaignLayout>{page}</CampaignLayout>;
5252
};
5353

54-
export const getStaticPaths: GetStaticPaths = async () => ({
55-
paths: [],
56-
fallback: "blocking",
57-
});
58-
59-
export const getStaticProps: GetStaticProps<CampaignPageProps> = async (context) => {
54+
export const getServerSideProps: GetServerSideProps<CampaignPageProps> = async (context) => {
6055
const { campaignId } = context.params as { campaignId?: string };
56+
const { res } = context;
57+
58+
// Cache SSR response at the edge to avoid repeated slow requests
59+
res.setHeader("Cache-Control", "s-maxage=300, stale-while-revalidate=900");
6160
const parsedCampaignId = campaignId ? parseInt(campaignId) : undefined;
6261

6362
const fallbackSeo: SeoProps = {
@@ -99,9 +98,9 @@ export const getStaticProps: GetStaticProps<CampaignPageProps> = async (context)
9998
image: campaign?.cover_image_url ?? fallbackSeo.image,
10099
};
101100

102-
return { props: { seo }, revalidate: 300 };
101+
return { props: { seo } };
103102
} catch {
104-
return { props: { seo: fallbackSeo }, revalidate: 60 };
103+
return { props: { seo: fallbackSeo } };
105104
} finally {
106105
clearTimeout(timeoutId);
107106
}

0 commit comments

Comments
 (0)