Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions app/api/predictions/[id]/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ const replicate = new Replicate({
auth: process.env.REPLICATE_API_TOKEN,
});

// Prevent Next.js / Vercel from caching responses
// See https://github.com/replicate/replicate-javascript/issues/136#issuecomment-1728053102
replicate.fetch = (url, options) => {
return fetch(url, { cache: "no-store", ...options });
};

export async function GET(request, {params}) {
const { id } = params;
const prediction = await replicate.predictions.get(id);
Expand Down
6 changes: 6 additions & 0 deletions app/api/predictions/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ const replicate = new Replicate({
auth: process.env.REPLICATE_API_TOKEN,
});

// Prevent Next.js / Vercel from caching responses
// See https://github.com/replicate/replicate-javascript/issues/136#issuecomment-1728053102
replicate.fetch = (url, options) => {
return fetch(url, { ...options, cache: "no-store" });
};

// In production and preview deployments (on Vercel), the VERCEL_URL environment variable is set.
// In development (on your local machine), the NGROK_HOST environment variable is set.
const WEBHOOK_HOST = process.env.VERCEL_URL
Expand Down