feat(MED-131): move jobs to /api/job/* secured with key
This commit is contained in:
9
app/api/job/handler/validate-api-key.ts
Normal file
9
app/api/job/handler/validate-api-key.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { NextRequest } from "next/server";
|
||||
|
||||
export default function validateApiKey(request: NextRequest) {
|
||||
const envApiKey = process.env.JOBS_API_TOKEN;
|
||||
const requestApiKey = request.headers.get('x-jobs-api-key');
|
||||
if (requestApiKey !== envApiKey) {
|
||||
throw new Error('Unauthorized');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user