mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 08:03:30 +02:00
Websocket loadbalancers might run in tcp mode, which makes it difficult to add the X-Forwarded-For header. Pass the IP in the query string instead.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
var http = require('http')
|
||||
var url = require('url')
|
||||
|
||||
var express = require('express')
|
||||
var validator = require('express-validator')
|
||||
@@ -116,28 +117,19 @@ module.exports = function(options) {
|
||||
res.render('index')
|
||||
})
|
||||
|
||||
app.get('/api/v1/appstate.js', function(req, res) {
|
||||
app.get('/api/v1/app/state.js', function(req, res) {
|
||||
var state = {
|
||||
config: {
|
||||
websocketUrl: (function() {
|
||||
var wsUrl = url.parse(options.websocketUrl, true)
|
||||
wsUrl.query.uip = req.ip
|
||||
return url.format(wsUrl)
|
||||
})()
|
||||
}
|
||||
, user: req.user
|
||||
}
|
||||
res.type('application/javascript')
|
||||
res.send('var GLOBAL_APPSTATE = ' + JSON.stringify({
|
||||
config: {
|
||||
websocketUrl: options.websocketUrl
|
||||
}
|
||||
, user: req.user
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
app.get('/api/v1/angular-appstate.js', function(req, res) {
|
||||
res.type('application/javascript')
|
||||
res.send('angular.module("stf.app-state")' +
|
||||
'.config(function(AppState){AppState.set(' +
|
||||
JSON.stringify({
|
||||
config: {
|
||||
websocketUrl: options.websocketUrl
|
||||
}
|
||||
, user: req.user
|
||||
}) +
|
||||
')})')
|
||||
res.send('var GLOBAL_APPSTATE = ' + JSON.stringify(state))
|
||||
})
|
||||
|
||||
app.get('/api/v1/app/user', function(req, res) {
|
||||
|
||||
Reference in New Issue
Block a user