1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-03 14:46:37 -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("Pragma", "no-cache");
if (req.method !== "POST") {
// 405 Method Not Allowed
return res.status(405).end();
// redirect GET requests to this endpoint to the contact form itself
if (req.method === "GET") {
return res.redirect(302, "/contact/");
}
const { body } = req;

View File

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