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:
parent
096ce154da
commit
9c45ecfdf1
8
app.js
8
app.js
@ -5,6 +5,7 @@
|
|||||||
// different license applies.
|
// different license applies.
|
||||||
|
|
||||||
console.log(`Initialising OwlBoard`)
|
console.log(`Initialising OwlBoard`)
|
||||||
|
const mode = process.env.NODE_ENV || "development"
|
||||||
|
|
||||||
// External Requires
|
// External Requires
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
@ -38,6 +39,7 @@ const limiter = rateLimit({
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Print version number:
|
// 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");
|
log.out(`app: Starting OwlBoard - Backend Version: ${version.app} - API versions: ${version.api}`, "init");
|
||||||
|
|
||||||
// Test for required vars:
|
// Test for required vars:
|
||||||
@ -75,6 +77,12 @@ app.use('/api/v1/register', regRtr)
|
|||||||
app.use('/api/v1/ldbs', authenticate)
|
app.use('/api/v1/ldbs', authenticate)
|
||||||
app.use('/api/v1/auth/test', authenticate) // Returns 401 if auth failed, 404 if successful.
|
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
|
// Start Express
|
||||||
app.listen(srvPort, srvListen, (error) =>{
|
app.listen(srvPort, srvListen, (error) =>{
|
||||||
if(!error) {
|
if(!error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user