1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-09-16 19:45:33 -04:00

stop terminating unexpected request methods to api endpoints

This commit is contained in:
2022-08-26 17:29:12 -04:00
parent 488bfac9c5
commit bdc8555b93
2 changed files with 3 additions and 8 deletions

View File

@@ -17,9 +17,9 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
res.setHeader("Cache-Control", "private, no-cache, no-store, must-revalidate"); res.setHeader("Cache-Control", "private, no-cache, no-store, must-revalidate");
res.setHeader("Pragma", "no-cache"); res.setHeader("Pragma", "no-cache");
if (req.method !== "POST") { // redirect GET requests to this endpoint to the contact form itself
// 405 Method Not Allowed if (req.method === "GET") {
return res.status(405).end(); return res.redirect(302, "/contact/");
} }
const { body } = req; const { body } = req;

View File

@@ -34,11 +34,6 @@ type SpotifyTrackSchema = {
const handler = async (req: NextApiRequest, res: NextApiResponse) => { const handler = async (req: NextApiRequest, res: NextApiResponse) => {
try { try {
if (req.method !== "GET") {
// 405 Method Not Allowed
return res.status(405).end();
}
// let Vercel edge cache results for 5 mins // let Vercel edge cache results for 5 mins
res.setHeader("Cache-Control", "public, max-age=0, s-maxage=300, stale-while-revalidate"); res.setHeader("Cache-Control", "public, max-age=0, s-maxage=300, stale-while-revalidate");