Skip to content

Commit

Permalink
fix(server): handle virtual path behind reverse proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans Kristian Flaatten committed Jun 10, 2016
1 parent 69e2c3b commit 4f44178
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ app.set('etag', false);
app.use(compression());
app.use(responseTime());

const VIRTUAL_PATH = process.env.VIRTUAL_PATH || '';

// Cors Headers
const corsHeaders = require('@starefossen/express-cors');
app.use(corsHeaders.middleware);

// Health Check
app.get('/CloudHealthCheck', require('./controllers/health'));
app.get(`${VIRTUAL_PATH}/CloudHealthCheck`, require('./controllers/health'));

// Routing API
app.use(require('./controllers/api'));
app.use(VIRTUAL_PATH, require('./controllers/api'));

// Not Found
app.use((req, res, next) => next(new HttpError('Not Found', 404)));
Expand Down

0 comments on commit 4f44178

Please sign in to comment.