Skip to content

Commit

Permalink
Merge pull request Expensify#7662 from mananjadhav/config/change-url-…
Browse files Browse the repository at this point in the history
…vars

Config URL Cleanup
  • Loading branch information
iwiznia authored Feb 28, 2022
2 parents 72daa6f + 5880cbf commit 53581fe
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 40 deletions.
6 changes: 3 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
EXPENSIFY_URL_CASH=https://new.expensify.com/
EXPENSIFY_URL_SECURE=https://secure.expensify.com.dev/
EXPENSIFY_URL_COM=https://www.expensify.com.dev/
NEW_EXPENSIFY_URL=https://new.expensify.com/
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
PUSHER_APP_KEY=ac6d22b891daae55283a
Expand Down
6 changes: 3 additions & 3 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
EXPENSIFY_URL_CASH=https://new.expensify.com/
EXPENSIFY_URL_SECURE=https://secure.expensify.com/
EXPENSIFY_URL_COM=https://www.expensify.com/
NEW_EXPENSIFY_URL=https://new.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
PUSHER_APP_KEY=268df511a204fbb60884
Expand Down
6 changes: 3 additions & 3 deletions .env.staging
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
EXPENSIFY_URL_CASH=https://staging.new.expensify.com/
EXPENSIFY_URL_SECURE=https://secure.expensify.com/
EXPENSIFY_URL_COM=https://www.expensify.com/
NEW_EXPENSIFY_URL=https://staging.new.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
PUSHER_APP_KEY=268df511a204fbb60884
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ For an M1 Mac, read this [SO](https://stackoverflow.com/c/expensify/questions/11
Creating an `.env` file is not necessary. We advise external contributors against it. It can lead to errors when
variables referenced here get updated since your local `.env` file is ignored.

- `EXPENSIFY_URL_CASH` - The root URL used for the website
- `EXPENSIFY_URL_SECURE` - The URL used to hit the Expensify secure API
- `EXPENSIFY_URL_COM` - The URL used to hit the Expensify API
- `NEW_EXPENSIFY_URL` - The root URL used for the website
- `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)
- `PUSHER_APP_KEY` - Key used to authenticate with Pusher.com
Expand Down
22 changes: 11 additions & 11 deletions src/CONFIG.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ import CONST from './CONST';

// Set default values to contributor friendly values to make development work out of the box without an .env file
const ENVIRONMENT = lodashGet(Config, 'ENVIRONMENT', CONST.ENVIRONMENT.DEV);
const expensifyCashURL = Url.addTrailingForwardSlash(lodashGet(Config, 'EXPENSIFY_URL_CASH', 'https://new.expensify.com/'));
const expensifyURL = Url.addTrailingForwardSlash(lodashGet(Config, 'EXPENSIFY_URL_COM', 'https://www.expensify.com/'));
const newExpensifyURL = Url.addTrailingForwardSlash(lodashGet(Config, 'NEW_EXPENSIFY_URL', 'https://new.expensify.com/'));
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_COM 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 All @@ -40,10 +40,10 @@ export default {
APP_NAME: 'NewExpensify',
AUTH_TOKEN_EXPIRATION_TIME: 1000 * 60 * 90,
EXPENSIFY: {
// Note: This will be EXACTLY what is set for EXPENSIFY_URL_COM whether the proxy is enabled or not.
URL_EXPENSIFY_COM: expensifyURL,
URL_EXPENSIFY_SECURE: secureURLRoot,
URL_EXPENSIFY_CASH: expensifyCashURL,
// Note: This will be EXACTLY what is set for EXPENSIFY_URL whether the proxy is enabled or not.
EXPENSIFY_URL: expensifyURL,
SECURE_EXPENSIFY_URL: secureURLRoot,
NEW_EXPENSIFY_URL: newExpensifyURL,
URL_API_ROOT: expensifyURLRoot,
PARTNER_NAME: lodashGet(Config, 'EXPENSIFY_PARTNER_NAME', 'chat-expensify-com'),
PARTNER_PASSWORD: lodashGet(Config, 'EXPENSIFY_PARTNER_PASSWORD', 'e21965746fd75f82bb66'),
Expand Down
8 changes: 3 additions & 5 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import Config from 'react-native-config';
import * as Url from './libs/Url';

const CLOUDFRONT_URL = 'https://d2k5nsl2zxldvw.cloudfront.net';
const ACTIVE_EXPENSIFY_URL = Url.addTrailingForwardSlash(lodashGet(Config, 'NEW_EXPENSIFY_URL', 'https://new.expensify.com'));
const USE_EXPENSIFY_URL = 'https://use.expensify.com';
const ACTIVE_ENVIRONMENT_NEW_EXPENSIFY_URL = Url.addTrailingForwardSlash(lodashGet(Config, 'EXPENSIFY_URL_CASH', 'https://new.expensify.com'));
const PLATFORM_OS_MACOS = 'Mac OS';
const ANDROID_PACKAGE_NAME = 'com.expensify.chat';

Expand All @@ -15,11 +15,11 @@ const CONST = {
// 50 megabytes in bytes
API_MAX_ATTACHMENT_SIZE: 52428800,
AVATAR_MAX_ATTACHMENT_SIZE: 6291456,
ACTIVE_ENVIRONMENT_NEW_EXPENSIFY_URL,
NEW_EXPENSIFY_URL: ACTIVE_EXPENSIFY_URL,
APP_DOWNLOAD_LINKS: {
ANDROID: `https://play.google.com/store/apps/details?id=${ANDROID_PACKAGE_NAME}`,
IOS: 'https://apps.apple.com/us/app/expensify-cash/id1530278510',
DESKTOP: `${ACTIVE_ENVIRONMENT_NEW_EXPENSIFY_URL}NewExpensify.dmg`,
DESKTOP: `${ACTIVE_EXPENSIFY_URL}NewExpensify.dmg`,
},
DATE: {
MOMENT_FORMAT_STRING: 'YYYY-MM-DD',
Expand Down Expand Up @@ -202,8 +202,6 @@ const CONST = {
FEES_URL: `${USE_EXPENSIFY_URL}/fees`,
CFPB_PREPAID_URL: 'https://cfpb.gov/prepaid',
STAGING_SECURE_URL: 'https://staging-secure.expensify.com/',
NEWDOT: 'new.expensify.com',
NEW_EXPENSIFY_URL: 'https://new.expensify.com',
STAGING_NEW_EXPENSIFY_URL: 'https://staging.new.expensify.com',
OPTION_TYPE: {
REPORT: 'report',
Expand Down
2 changes: 1 addition & 1 deletion src/components/AddressSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const AddressSearch = (props) => {
}}
requestUrl={{
useOnPlatform: 'web',
url: `${CONFIG.EXPENSIFY.URL_EXPENSIFY_COM}api?command=Proxy_GooglePlaces&proxyUrl=`,
url: `${CONFIG.EXPENSIFY.EXPENSIFY_URL}api?command=Proxy_GooglePlaces&proxyUrl=`,
}}
textInputProps={{
InputComp: TextInput,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ const ImageRenderer = (props) => {

// Update the image URL so the images can be accessed depending on the config environment
previewSource = previewSource.replace(
Config.EXPENSIFY.URL_EXPENSIFY_COM,
Config.EXPENSIFY.EXPENSIFY_URL,
Config.EXPENSIFY.URL_API_ROOT,
);
source = source.replace(
Config.EXPENSIFY.URL_EXPENSIFY_COM,
Config.EXPENSIFY.EXPENSIFY_URL,
Config.EXPENSIFY.URL_API_ROOT,
);

Expand Down
4 changes: 2 additions & 2 deletions src/libs/HttpUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function processHTTPRequest(url, method = 'get', body = null, canCancel = true)
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 All @@ -60,7 +60,7 @@ function xhr(command, data, type = CONST.NETWORK.METHOD.POST, shouldUseSecure =
* @returns {Promise}
*/
function download(relativePath) {
const siteRoot = CONFIG.EXPENSIFY.URL_EXPENSIFY_CASH;
const siteRoot = CONFIG.EXPENSIFY.NEW_EXPENSIFY_URL;

// Strip leading slashes and periods from relative path, if present
const strippedRelativePath = relativePath.charAt(0) === '/' || relativePath.charAt(0) === '.'
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function openOldDotLink(url) {
}

function buildOldDotURL({shortLivedAuthToken}) {
return `${CONFIG.EXPENSIFY.URL_EXPENSIFY_COM}${url}${url.indexOf('?') === -1 ? '?' : '&'}authToken=${shortLivedAuthToken}&email=${encodeURIComponent(currentUserEmail)}`;
return `${CONFIG.EXPENSIFY.EXPENSIFY_URL}${url}${url.indexOf('?') === -1 ? '?' : '&'}authToken=${shortLivedAuthToken}&email=${encodeURIComponent(currentUserEmail)}`;
}

asyncOpenURL(API.GetShortLivedAuthToken(), buildOldDotURL);
Expand Down
2 changes: 1 addition & 1 deletion src/libs/getPlaidLinkTokenParameters/index.ios.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import CONFIG from '../../CONFIG';

export default () => ({redirect_uri: `${CONFIG.EXPENSIFY.URL_EXPENSIFY_CASH}partners/plaid/oauth_ios`});
export default () => ({redirect_uri: `${CONFIG.EXPENSIFY.NEW_EXPENSIFY_URL}partners/plaid/oauth_ios`});
2 changes: 1 addition & 1 deletion src/libs/getPlaidLinkTokenParameters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import CONFIG from '../../CONFIG';

export default () => {
const bankAccountRoute = window.location.href.includes('personal') ? ROUTES.BANK_ACCOUNT_PERSONAL : ROUTES.BANK_ACCOUNT;
return {redirect_uri: `${CONFIG.EXPENSIFY.URL_EXPENSIFY_CASH}${bankAccountRoute}`};
return {redirect_uri: `${CONFIG.EXPENSIFY.NEW_EXPENSIFY_URL}${bankAccountRoute}`};
};
2 changes: 1 addition & 1 deletion src/pages/EnablePayments/TermsPage/LongTermsForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const LongTermsForm = () => (
{' '}
{Localize.translateLocal('termsStep.longTermsForm.contactExpensifyPayments2')}
{' '}
{CONST.NEWDOT}
{CONST.NEW_EXPENSIFY_URL}
.
</Text>
<Text style={[styles.mb6, styles.textMicroSupporting]}>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ErrorPage/ErrorBodyText/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const propTypes = {
const ErrorBodyText = props => (
<Text>
{`${props.translate('genericErrorPage.body.helpTextMobile')} `}
<TextLink href={CONST.ACTIVE_ENVIRONMENT_NEW_EXPENSIFY_URL} style={[styles.link]}>
<TextLink href={CONST.NEW_EXPENSIFY_URL} style={[styles.link]}>
{props.translate('genericErrorPage.body.helpTextWeb')}
</TextLink>
</Text>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ReimbursementAccount/BankAccountStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class BankAccountStep extends React.Component {
const shouldReinitializePlaidLink = this.props.plaidLinkOAuthToken && this.props.receivedRedirectURI && this.props.achData.subStep !== CONST.BANK_ACCOUNT.SUBSTEP.MANUAL;
const subStep = shouldReinitializePlaidLink ? CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID : this.props.achData.subStep;
const plaidDesktopMessage = getPlaidDesktopMessage();
const bankAccountRoute = `${CONFIG.EXPENSIFY.URL_EXPENSIFY_CASH}${ROUTES.BANK_ACCOUNT}`;
const bankAccountRoute = `${CONFIG.EXPENSIFY.NEW_EXPENSIFY_URL}${ROUTES.BANK_ACCOUNT}`;

return (
<View style={[styles.flex1, styles.justifyContentBetween]}>
Expand Down
2 changes: 1 addition & 1 deletion web/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if (process.env.USE_WEB_PROXY === 'false') {
let host = 'www.expensify.com';

// If we are testing against the staging API then we must use the correct host here or nothing with work.
if (/staging/.test(process.env.EXPENSIFY_URL_COM)) {
if (/staging/.test(process.env.EXPENSIFY_URL)) {
host = 'staging.expensify.com';
}

Expand Down

0 comments on commit 53581fe

Please sign in to comment.