Add proxy set:

- Add app.set('trust proxy', 3)
- Add route /api/v1/ip when in development mode

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-04-06 22:15:57 +01:00
parent 096ce154da
commit 9c45ecfdf1

8
app.js
View File

@ -5,6 +5,7 @@
// different license applies.
console.log(`Initialising OwlBoard`)
const mode = process.env.NODE_ENV || "development"
// External Requires
const express = require('express');
@ -38,6 +39,7 @@ const limiter = rateLimit({
})
// Print version number:
log.out(`app: Starting OwlBoard in ${mode} mode`, "init")
log.out(`app: Starting OwlBoard - Backend Version: ${version.app} - API versions: ${version.api}`, "init");
// Test for required vars:
@ -75,6 +77,12 @@ app.use('/api/v1/register', regRtr)
app.use('/api/v1/ldbs', authenticate)
app.use('/api/v1/auth/test', authenticate) // Returns 401 if auth failed, 404 if successful.
// Number of proxies:
app.set('trust proxy', 3)
mode === "development"
? app.get('/api/v1/ip', (request, response) => response.send(request.ip))
: null
// Start Express
app.listen(srvPort, srvListen, (error) =>{
if(!error) {