1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-05 10:39:25 +02:00

Add a poor reverse proxy for local development, the main difference being that everything except websockets now goes through the same port. Makes it easier to understand the production url layout.

This commit is contained in:
Simo Kinnunen 2014-10-23 13:28:18 +09:00
parent cd1f9108ce
commit 6d88a28a2c
3 changed files with 140 additions and 54 deletions

View file

@ -9,7 +9,6 @@ var serveFavicon = require('serve-favicon')
var serveStatic = require('serve-static')
var csrf = require('csurf')
var Promise = require('bluebird')
var httpProxy = require('http-proxy')
var compression = require('compression')
var logger = require('../../util/logger')
@ -29,11 +28,6 @@ module.exports = function(options) {
var log = logger.createLogger('app')
, app = express()
, server = http.createServer(app)
, proxy = httpProxy.createProxyServer()
proxy.on('error', function(err) {
log.error('Proxy had an error', err.stack)
})
app.use('/static/docs', markdownServe.middleware({
rootDirectory: pathutil.root('node_modules/stf-docs')
@ -89,27 +83,6 @@ module.exports = function(options) {
, authUrl: options.authUrl
}))
// Proxied requests must come before any body parsers. These proxies are
// here mainly for convenience, they should be replaced with proper reverse
// proxies in production.
app.all('/api/v1/s/image/*', function(req, res) {
proxy.web(req, res, {
target: options.storagePluginImageUrl
})
})
app.all('/api/v1/s/apk/*', function(req, res) {
proxy.web(req, res, {
target: options.storagePluginApkUrl
})
})
app.all('/api/v1/s/*', function(req, res) {
proxy.web(req, res, {
target: options.storageUrl
})
})
app.use(bodyParser.json())
app.use(csrf())
app.use(validator())