Download src/proxy/auth.ts from dakaca/oai-proxy: direct link, hf CLI and curl.
- Browser
- Download file 412 Bytes
-
https://huggingface.co/spaces/dakaca/oai-proxy/resolve/main/src/proxy/auth.ts
- Command line
-
hf download hf://spaces/dakaca/oai-proxy/src/proxy/auth.ts
-
curl -L -o auth.ts https://huggingface.co/spaces/dakaca/oai-proxy/resolve/main/src/proxy/auth.ts
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" }); | |
| } | |
| }; | |