Use 'env' schema module, use template string, use lowercase header key

This commit is contained in:
2024-12-19 16:42:39 -06:00
parent cc2f9a42d2
commit 2d9893fa7c

View File

@@ -2,6 +2,7 @@ import { readItem, readItems } from "@directus/sdk";
import type { NextApiRequest, NextApiResponse } from "next";
import { z } from "zod";
import directus from "../../utils/directus";
import { env } from "../../env/server.mjs";
async function getURLs(
type: string,
@@ -60,10 +61,7 @@ export default async function handler(
if (req.method !== "POST")
return res.status(405).json({ message: "Method not allowed" });
if (
req.headers["Authorization"] !==
"Bearer " + process.env.DIRECTUS_REVALIDATE_KEY
)
if (req.headers["authorization"] !== `Bearer ${env.DIRECTUS_REVALIDATE_KEY}`)
return res.status(401).json({ message: "Invalid token" });
try {