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:
@@ -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;
|
||||||
|
@@ -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");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user