mirror of
https://github.com/filecoffee/filehost.git
synced 2024-11-13 19:49:56 +01:00
Update file.routes.js
This commit is contained in:
parent
8075a58510
commit
fe991ae2f7
1 changed files with 4 additions and 1 deletions
|
@ -3,8 +3,11 @@ const { uploadFile, getFile } = require("../controllers/file.controller");
|
|||
|
||||
const router = express.Router();
|
||||
|
||||
const apiKeys = process.env.API_KEYS.split(",");
|
||||
const allowPublicUploads = process.env.ALLOW_PUBLIC;
|
||||
|
||||
const authenticate = (req, res, next) => {
|
||||
const apiKey = req.headers["x-api-key"];
|
||||
const apiKey = req.headers["x-api-key"] || req.query.api;
|
||||
if (!apiKey || !apiKeys.includes(apiKey)) {
|
||||
if (allowPublicUploads) {
|
||||
req.isPublicUpload = true;
|
||||
|
|
Loading…
Reference in a new issue