Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/cache prod #60

Merged
merged 6 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/nextjs/app/api/grants/review/route.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { NextResponse } from "next/server";
import { revalidatePath } from "next/cache";
import { NextRequest, NextResponse } from "next/server";
import { getAllGrantsForReview } from "~~/services/database/grants";

export async function GET() {
export async function GET(request: NextRequest) {
try {
const path = request.nextUrl.searchParams.get("path");
const grants = await getAllGrantsForReview();
if (path) revalidatePath(path);
return NextResponse.json({ data: grants });
} catch (error) {
technophile-04 marked this conversation as resolved.
Show resolved Hide resolved
return NextResponse.json(
Expand Down
6 changes: 3 additions & 3 deletions packages/nextjs/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { ScaffoldEthAppWithProviders } from "~~/components/ScaffoldEthAppWithPro
import { ThemeProvider } from "~~/components/ThemeProvider";
import "~~/styles/globals.css";

const baseUrl = process.env.NEXT_PUBLIC_VERCEL_URL
? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
: `http://localhost:${process.env.PORT}`;
const baseUrl = process.env.VERCEL_URL
? `https://${process.env.VERCEL_URL}`
: `http://localhost:${process.env.PORT || 3000}`;
carletex marked this conversation as resolved.
Show resolved Hide resolved
const imageUrl = `${baseUrl}/thumbnail.jpg`;

export const metadata: Metadata = {
Expand Down
2 changes: 2 additions & 0 deletions packages/nextjs/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { EcosystemGrants } from "./_components/EcosystemGrants";
import { GrantsStats } from "./_components/GrantsStats";
import { HomepageHero } from "./_components/HomepageHero";

export const revalidate = 21600; // 6 hours

const Home = () => {
technophile-04 marked this conversation as resolved.
Show resolved Hide resolved
return (
<>
Expand Down
8 changes: 4 additions & 4 deletions packages/nextjs/utils/scaffold-eth/getMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export const getMetadata = ({
description: string;
imageRelativePath?: string;
}): Metadata => {
const baseUrl = process.env.NEXT_PUBLIC_VERCEL_URL
? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
: `http://localhost:${process.env.PORT}`;
const imageUrl = `${baseUrl}${imageRelativePath}`;
const baseUrl = process.env.VERCEL_URL
? `https://${process.env.VERCEL_URL}`
: `http://localhost:${process.env.PORT || 3000}`;
const imageUrl = `${baseUrl}/${imageRelativePath}`;
return {
title: title,
description: description,
Expand Down
Loading