Skip to content

Commit

Permalink
Use environment variables in .env-file
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Panneels committed Dec 19, 2019
1 parent 5dcb0e2 commit c784df3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 9 additions & 1 deletion lib/proxy.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
// heavily inspired by https://github.com/SAP/connect-openui5/blob/master/lib/proxy.js
const url = require("url");
const httpProxy = require("http-proxy");
const dotenv = require("dotenv");

// Call dotenv, so that contents in the file are stored in the environment variables
dotenv.config();

const env = {
noProxy: process.env.NO_PROXY || process.env.no_proxy,
httpProxy: process.env.HTTP_PROXY || process.env.http_proxy,
httpsProxy: process.env.HTTPS_PROXY || process.env.https_proxy
httpsProxy: process.env.HTTPS_PROXY || process.env.https_proxy,
username: process.env.PROXY_USERNAME || process.env.proxy_username,
password: process.env.PROXY_PASSWORD || process.env.proxy_password
};

function getProxyUri(uri) {
Expand Down Expand Up @@ -61,6 +67,8 @@ function createUri(uriParam, baseUri) {

module.exports = function({resources, options}) {
let proxyServerParameters = {};

proxyServerParameters.auth = env.username + ":" + env.password;
if (options.configuration.auth) {
proxyServerParameters.auth = options.configuration.auth;
}
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ui5-middleware-proxy-basicauth",
"version": "0.0.5",
"version": "0.0.6",
"description": "UI5 Middleware Proxy with Basic auth",
"author": "Koen Schouten",
"license": "Apache-2.0",
Expand All @@ -9,6 +9,7 @@
"url": "https://github.com/Schoutenk/ui5-middleware-proxy-basicauth"
},
"dependencies": {
"http-proxy": "^1.18.0"
"http-proxy": "^1.18.0",
"dotenv": "^8.2.0"
}
}

0 comments on commit c784df3

Please sign in to comment.