API-Ke via .env hinzu gefügt

This commit is contained in:
2025-11-05 09:53:37 +00:00
parent e6a97ff1a0
commit 8e8a6b3b13
5 changed files with 342 additions and 169 deletions
+5 -1
View File
@@ -16,6 +16,7 @@ const disttable = [
]
let APIHOST = process.env.APIHOST || 'http://localhost:3005'
const API_KEY = process.env.API_KEY
/* GET home page. */
@@ -25,9 +26,12 @@ router.get('/:cmd', async function(req, res, next) {
const cmd = req.params.cmd
const pretty = (req.query.pretty !== undefined)
const lng = getLanguage()
let url = APIHOST + '/api' + req.originalUrl.slice(4) + `&lng=${lng}`
try {
const response = await axios.get(encodeURI(url));
const response = await axios.get(encodeURI(url) , {
headers: {'X-API-Key': API_KEY}
});
if (response.status !== 200) {
res.json({err: `${trans('ESYSCALL')} status=${response.status}`})
}