API-Ke via .env hinzu gefügt
This commit is contained in:
+5
-1
@@ -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}`})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user