Spaces:
Configuration error
Configuration error
Download src/api/middleware.js from sdsdsd55415/pcstore: direct link, hf CLI and curl.
- Browser
- Download file 791 Bytes
-
https://huggingface.co/spaces/sdsdsd55415/pcstore/resolve/main/src/api/middleware.js
- Command line
-
hf download hf://spaces/sdsdsd55415/pcstore/src/api/middleware.js
-
curl -L -o middleware.js https://huggingface.co/spaces/sdsdsd55415/pcstore/resolve/main/src/api/middleware.js
791 Bytes
| const Settings = require('../models/Settings'); | |
| const authMiddleware = async (req, res, next) => { | |
| // Authentication disabled for public shop API | |
| next(); | |
| /* Original auth code (disabled): | |
| try { | |
| const apiKey = req.headers['x-api-key']; | |
| if (!apiKey) { | |
| return res.status(401).json({ error: 'API Key missing' }); | |
| } | |
| const validKey = await Settings.findOne({ key: 'api_secret_key' }); | |
| if (!validKey || validKey.value !== apiKey) { | |
| return res.status(403).json({ error: 'Invalid API Key' }); | |
| } | |
| next(); | |
| } catch (e) { | |
| console.error("Auth Error:", e); | |
| res.status(500).json({ error: 'Server Error' }); | |
| } | |
| */ | |
| }; | |
| module.exports = authMiddleware; | |