adds auth
This commit is contained in:
parent
e1606e3f66
commit
bbfb922dab
|
@ -0,0 +1,15 @@
|
|||
import type { Request, Response, NextFunction } from "express";
|
||||
|
||||
const PROXY_KEY = process.env.PROXY_KEY;
|
||||
|
||||
export function auth(req: Request, res: Response, next: NextFunction) {
|
||||
if (!PROXY_KEY) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
if (req.headers.authorization === `Bearer ${PROXY_KEY}`) {
|
||||
next();
|
||||
} else {
|
||||
res.status(401).json({ error: "Unauthorized" });
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue