diff options
| -rw-r--r-- | app/routes/api.posts.tsx | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/app/routes/api.posts.tsx b/app/routes/api.posts.tsx index 2d5637c..8ef7639 100644 --- a/app/routes/api.posts.tsx +++ b/app/routes/api.posts.tsx @@ -14,6 +14,12 @@ export async function action({ request }: Route.ActionArgs) { return Response.json({ error: "Method not allowed" }, { status: 405 }); } + const token = process.env.REGISTER_TOKEN; + const auth = request.headers.get("Authorization") ?? ""; + if (!token || auth !== `Bearer ${token}`) { + return Response.json({ error: "Unauthorized" }, { status: 401 }); + } + let content: string; const ct = request.headers.get("content-type") ?? ""; if (ct.includes("application/json")) { |
