-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
secure flow of .env params configured
- Loading branch information
1 parent
47b0f58
commit e4d25b2
Showing
8 changed files
with
53 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
REACT_APP_API_ENDPOINT="http://sandbox.gonebusy.com/api/v1" | ||
REACT_APP_API_ENDPOINT="v1" | ||
REACT_APP_TOKEN="Token af9094c6d46658e60cde12e34ad26979" | ||
|
||
CI="true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
REACT_APP_SERVICE_ID=7891245607 | ||
REACT_APP_GONEBUSY_TOKEN="Token af9094c6d46658e60cde12e34ad26979" | ||
REACT_APP_API_HOST="http://sandbox.gonebusy.com" | ||
REACT_APP_API_PATH="/api/v1" | ||
REACT_APP_IS_PROXIED="true" | ||
REACT_APP_PROXY_HOST="http://localhost:3000" | ||
GONEBUSY_TOKEN="Token af9094c6d46658e60cde12e34ad26979" | ||
GONEBUSY_API_HOST="http://sandbox.gonebusy.com" | ||
GONEBUSY_API_PATH="/api/v1" | ||
GONEBUSY_IS_PROXIED="true" | ||
GONEBUSY_PROXY_HOST="http://localhost:3000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
REACT_APP_API_ENDPOINT="http://sandbox.gonebusy.com/api/v1" | ||
REACT_APP_TOKEN="Token af9094c6d46658e60cde12e34ad26979" | ||
|
||
CI="true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,28 @@ | ||
const url = require('url'); | ||
const env = process.env; | ||
const reactAppServiceId = env['REACT_APP_SERVICE_ID']; | ||
const reactAppGonebusyToken = env['REACT_APP_GONEBUSY_TOKEN']; | ||
const gonebusyApiHost = env['REACT_APP_API_HOST']; | ||
const gonebusyApiPath = env['REACT_APP_API_PATH']; | ||
const gonebusyIsProxied = env['REACT_APP_IS_PROXIED']; | ||
const gonebusyProxyHost = env['REACT_APP_PROXY_HOST']; | ||
|
||
const is_proxied = !!(gonebusyIsProxied && JSON.parse(gonebusyIsProxied)); | ||
const envToken = env['GONEBUSY_TOKEN']; | ||
const envApiHost = env['GONEBUSY_API_HOST']; | ||
const envApiPath = env['GONEBUSY_API_PATH']; | ||
const envIsProxied = env['GONEBUSY_IS_PROXIED']; | ||
const envProxyHost = env['GONEBUSY_PROXY_HOST']; | ||
|
||
const clientApiEndpoint = url.resolve((is_proxied ? gonebusyProxyHost : gonebusyApiHost) || '', gonebusyApiPath); | ||
const clientToken = is_proxied ? 'none' : reactAppGonebusyToken; | ||
const middlewareProxyHost = is_proxied ? gonebusyApiHost : undefined; | ||
const middlewareToken = is_proxied ? reactAppGonebusyToken : undefined; | ||
const is_proxied = !!(envIsProxied && JSON.parse(envIsProxied)); | ||
|
||
console.log("to change the way we process .env so that it won't appear in plain JS", is_proxied); | ||
const clientApiEndpoint = url.resolve((is_proxied ? envProxyHost : envApiHost) || '', envApiPath); | ||
const clientToken = is_proxied ? 'none' : envToken; | ||
|
||
const middlewareProxyHost = is_proxied ? envApiHost : undefined; | ||
const middlewareToken = is_proxied ? envToken : undefined; | ||
|
||
module.exports = { | ||
service_id: reactAppServiceId, | ||
clientApiEndpoint, | ||
clientToken, | ||
middlewareProxyHost, | ||
middlewarePath: gonebusyApiPath, | ||
middlewareToken, | ||
client: { | ||
REACT_APP_API_ENDPOINT: clientApiEndpoint, | ||
REACT_APP_TOKEN: clientToken | ||
}, | ||
middleware: { | ||
proxy: middlewareProxyHost, | ||
path: envApiPath, | ||
token: middlewareToken | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters