var express = require('express'),
    path = require('path'),
    helpers = require('./helpers'),
    loginUrl = '/proxy/login/' + helpers.guid(),
    router = express.Router({
        caseSensitive: false,
        strict: false
    }),
    httpProxy = require('http-proxy'),
    urlParser = require('body-parser').urlencoded({extended: true}),
    proxy = httpProxy.createProxyServer({
        target: {
            host: helpers.env('PROXY_TARGET_HOST', 'smartive.ch'),
            port: helpers.env('PROXY_TARGET_PORT', '80')
        }
    });

exports = module.exports = function (passport) {
    if (!passport) throw new Error('Passport auth must be set.');

    router
        .route(loginUrl)
        .get(function (req, res) {
            if (req.query.logo) {
                return res.sendFile(path.join(__dirname, 'logo.png'));
            }
            res.sendFile(path.join(__dirname, 'login.html'));
        })
        .post(urlParser, passport.authenticate('local', {failureRedirect: loginUrl}), function (req, res) {
            res.redirect('/');
        });

    router
        .route('/*')
        .all(function (req, res) {
            if (!req.isAuthenticated()) return res.redirect(loginUrl);
            proxy.web(req, res);
        });

    return router;
};
@@ -340,74 +340,103 @@
 ue%7D)
-,%0A    proxy = httpProxy.createProxyServer(%7B%0A        
+;%0A%0Avar options = %7Bsecure: false%7D;%0Aif(helpers.env('PROXY_TARGET_HOST'))%7B%0A    options.
 target
-:
+ =
  %7B%0A
-    
     
@@ -483,23 +483,21 @@
 ', '
-smartiv
+googl
 e.ch'),%0A
     
@@ -492,20 +492,16 @@
 e.ch'),%0A
-    
         
@@ -543,33 +543,151 @@
 T', 
-'
 80
-'
 )%0A    
-    %7D%0A    %7D
+%7D%0A%7D else %7B%0A    options.target = helpers.env('PROXY_TARGET', 'http://google.ch');%0A%7D%0Avar proxy = httpProxy.createProxyServer(options
 );%0A%0A
+%0A
 expo

change router logic to enable whole target url