Skip to content

Commit

Permalink
config: Updated secure url
Browse files Browse the repository at this point in the history
  • Loading branch information
mananjadhav committed Feb 23, 2022
1 parent 6d8acfc commit 543585a
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NEW_EXPENSIFY_URL=https://new.expensify.com/
EXPENSIFY_URL_SECURE=https://secure.expensify.com.dev/
SECURE_EXPENSIFY_URL=https://secure.expensify.com.dev/
EXPENSIFY_URL=https://www.expensify.com.dev/
EXPENSIFY_PARTNER_NAME=chat-expensify-com
EXPENSIFY_PARTNER_PASSWORD=e21965746fd75f82bb66
Expand Down
2 changes: 1 addition & 1 deletion .env.production
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NEW_EXPENSIFY_URL=https://new.expensify.com/
EXPENSIFY_URL_SECURE=https://secure.expensify.com/
SECURE_EXPENSIFY_URL=https://secure.expensify.com/
EXPENSIFY_URL=https://www.expensify.com/
EXPENSIFY_PARTNER_NAME=chat-expensify-com
EXPENSIFY_PARTNER_PASSWORD=e21965746fd75f82bb66
Expand Down
2 changes: 1 addition & 1 deletion .env.staging
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NEW_EXPENSIFY_URL=https://staging.new.expensify.com/
EXPENSIFY_URL_SECURE=https://secure.expensify.com/
SECURE_EXPENSIFY_URL=https://secure.expensify.com/
EXPENSIFY_URL=https://www.expensify.com/
EXPENSIFY_PARTNER_NAME=chat-expensify-com
EXPENSIFY_PARTNER_PASSWORD=e21965746fd75f82bb66
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Creating an `.env` file is not necessary. We advise external contributors agains
variables referenced here get updated since your local `.env` file is ignored.

- `NEW_EXPENSIFY_URL` - The root URL used for the website
- `EXPENSIFY_URL_SECURE` - The URL used to hit the Expensify secure API
- `SECURE_EXPENSIFY_URL` - The URL used to hit the Expensify secure API
- `EXPENSIFY_URL` - The URL used to hit the Expensify API
- `EXPENSIFY_PARTNER_NAME` - Constant used for the app when authenticating.
- `EXPENSIFY_PARTNER_PASSWORD` - Another constant used for the app when authenticating. (This is OK to be public)
Expand Down
10 changes: 5 additions & 5 deletions src/CONFIG.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ const newExpensifyURL = Url.addTrailingForwardSlash(lodashGet(Config, 'NEW_EXPEN
const expensifyURL = Url.addTrailingForwardSlash(lodashGet(Config, 'EXPENSIFY_URL', 'https://www.expensify.com/'));
const ngrokURL = Url.addTrailingForwardSlash(lodashGet(Config, 'NGROK_URL', ''));
const secureNgrokURL = Url.addTrailingForwardSlash(lodashGet(Config, 'SECURE_NGROK_URL', ''));
const expensifyURLSecure = Url.addTrailingForwardSlash(lodashGet(
Config, 'EXPENSIFY_URL_SECURE', 'https://secure.expensify.com/',
const secureExpensifyUrl = Url.addTrailingForwardSlash(lodashGet(
Config, 'SECURE_EXPENSIFY_URL', 'https://secure.expensify.com/',
));
const useNgrok = lodashGet(Config, 'USE_NGROK', 'false') === 'true';
const useWebProxy = lodashGet(Config, 'USE_WEB_PROXY', 'true') === 'true';
const expensifyComWithProxy = getPlatform() === 'web' && useWebProxy ? '/' : expensifyURL;

// Throw errors on dev if config variables are not set correctly
if (ENVIRONMENT === CONST.ENVIRONMENT.DEV) {
if (!useNgrok && expensifyURL.includes('dev') && !expensifyURLSecure.includes('dev')) {
throw new Error('EXPENSIFY_URL_SECURE must end with .dev when EXPENSIFY_URL ends with .dev');
if (!useNgrok && expensifyURL.includes('dev') && !secureExpensifyUrl.includes('dev')) {
throw new Error('SECURE_EXPENSIFY_URL must end with .dev when EXPENSIFY_URL ends with .dev');
}

if (useNgrok && !secureNgrokURL) {
throw new Error('SECURE_NGROK_URL must be defined in .env when USE_NGROK=true');
}
}

const secureURLRoot = useNgrok && secureNgrokURL ? secureNgrokURL : expensifyURLSecure;
const secureURLRoot = useNgrok && secureNgrokURL ? secureNgrokURL : secureExpensifyUrl;

// Ngrok helps us avoid many of our cross-domain issues with connecting to our API
// and is required for viewing images on mobile and for developing on android
Expand Down
2 changes: 1 addition & 1 deletion src/libs/HttpUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function processHTTPRequest(url, method = 'get', body = null) {
function xhr(command, data, type = CONST.NETWORK.METHOD.POST, shouldUseSecure = false) {
const formData = new FormData();
_.each(data, (val, key) => formData.append(key, val));
let apiRoot = shouldUseSecure ? CONFIG.EXPENSIFY.URL_EXPENSIFY_SECURE : CONFIG.EXPENSIFY.URL_API_ROOT;
let apiRoot = shouldUseSecure ? CONFIG.EXPENSIFY.SECURE_EXPENSIFY_URL : CONFIG.EXPENSIFY.URL_API_ROOT;

if (shouldUseSecure && shouldUseSecureStaging) {
apiRoot = CONST.STAGING_SECURE_URL;
Expand Down

0 comments on commit 543585a

Please sign in to comment.