oai-proxy / src /proxy /auth.ts
Xeeph's picture
Duplicate from idosal/oai-proxy
5bddbd8
raw
history blame contribute delete
No virus
412 Bytes
import type { Request, Response, NextFunction } from "express";
const PROXY_KEY = process.env.PROXY_KEY;
export const auth = (req: Request, res: Response, next: NextFunction) => {
if (!PROXY_KEY) {
next();
return;
}
if (req.headers.authorization === `Bearer ${PROXY_KEY}`) {
delete req.headers.authorization;
next();
} else {
res.status(401).json({ error: "Unauthorized" });
}
};