diff --git a/pages/api/cron/artwork-email.ts b/pages/api/cron/artwork-email.ts index a8a0533..bce9093 100644 --- a/pages/api/cron/artwork-email.ts +++ b/pages/api/cron/artwork-email.ts @@ -41,7 +41,7 @@ export default async function handler( for (const show of shows) { let showEmailed = false; - let artwork = show.showArtwork.url + "?fm=jpg"; + let artwork = show.artwork.url + "?fm=jpg"; for (const artist of show.artistsCollection.items) { if (artist.email && !emailedArtists.has(artist.email)) { diff --git a/pages/api/revalidate/show-artwork.ts b/pages/api/revalidate/show-artwork.ts index b2eaff1..6cf0934 100644 --- a/pages/api/revalidate/show-artwork.ts +++ b/pages/api/revalidate/show-artwork.ts @@ -14,11 +14,20 @@ export default async function handler( req: NextApiRequest, res: NextApiResponse ) { - const origin = req.headers.origin; - const allowedOrigin = process.env.NEXT_PUBLIC_SITE_URL; + // const origin = req.headers.origin; + // const allowedOrigin = process.env.NEXT_PUBLIC_SITE_URL; - if (origin !== allowedOrigin) { - return res.status(403).json({ error: "Forbidden" }); + // if (origin !== allowedOrigin) { + // return res.status(403).json({ error: "Forbidden" }); + // } + + res.setHeader("Access-Control-Allow-Origin", "https://app.contentful.com"); + res.setHeader("Access-Control-Allow-Methods", "GET,POST,OPTIONS"); + res.setHeader("Access-Control-Allow-Headers", "*"); + + // Handle preflight requests + if (req.method === "OPTIONS") { + return res.status(200).end(); } if (req.method === "POST") { diff --git a/types/shared.d.ts b/types/shared.d.ts index 6c9f889..3f0e66a 100644 --- a/types/shared.d.ts +++ b/types/shared.d.ts @@ -122,7 +122,7 @@ export interface ShowInterface { }; content: Content; status?: string; - showArtwork?: CoverImage; + artwork?: CoverImage; } export type PastShowSchema = {