Skip to content

Commit

Permalink
update config and .env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
thienlnam committed Nov 18, 2020
1 parent 5ed1424 commit 6f56f04
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
6 changes: 4 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/**
* Rename this file to `.env` and put your local config in here
*/
EXPENSIFY_SITE_ROOT=https://expensify.com.dev/
EXPENSIFY_SITE_ROOT=https://www.expensify.com.dev/
EXPENSIFY_PARTNER_NAME=android
EXPENSIFY_PARTNER_PASSWORD=c3a9ac418ea3f152aae2
PUSHER_APP_KEY=ac6d22b891daae55283a
PUSHER_APP_KEY=ac6d22b891daae55283a
NGROK_URL=
USE_NGROK=false
4 changes: 2 additions & 2 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
EXPENSIFY_CASH_SITE_ROOT=https://chat.expensify.com/
EXPENSIFY_SITE_ROOT=https://expensify.com/
EXPENSIFY_CASH_SITE_ROOT=https://www.chat.expensify.com/
EXPENSIFY_SITE_ROOT=https://www.expensify.com/
EXPENSIFY_PARTNER_NAME=chat-expensify-com
EXPENSIFY_PARTNER_PASSWORD=e21965746fd75f82bb66
PUSHER_APP_KEY=268df511a204fbb60884
15 changes: 10 additions & 5 deletions src/CONFIG.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import {Platform} from 'react-native';
import Config from 'react-native-config';

// Updates the API_ROOT and SITE_ROOT to use the NGROK route if .env flag is enabled
// Otherwise it will use the value inside config.EXPENSIFY_SITE_ROOT
// DEFAULT_SITE_ROOT will always contain the default site root of www.expensify.com or www.expensify.com.dev
const expensifySiteURL = Config.USE_NGROK === 'true' && Config.NGROK_URL
? Config.NGROK_URL
: Config.EXPENSIFY_SITE_ROOT;

export default {
AUTH_TOKEN_EXPIRATION_TIME: 1000 * 60 * 90,
EXPENSIFY: {
API_ROOT: Config.NGROK_URL
? `${Config.NGROK_URL}/api?`
: `${Config.EXPENSIFY_SITE_ROOT}api?`,
NGROK_URL: Config.NGROK_URL,
DEFAULT_SITE_ROOT: Config.EXPENSIFY_SITE_ROOT,
SITE_ROOT: expensifySiteURL,
CASH_SITE_ROOT: Config.EXPENSIFY_CASH_ROOT,
SITE_ROOT: Config.EXPENSIFY_SITE_ROOT,
API_ROOT: `${expensifySiteURL}api?`,
PARTNER_NAME: Config.EXPENSIFY_PARTNER_NAME,
PARTNER_PASSWORD: Config.EXPENSIFY_PARTNER_PASSWORD,
},
Expand Down
9 changes: 6 additions & 3 deletions src/pages/home/report/ReportActionItemFragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@ class ReportActionItemFragment extends React.PureComponent {
: htmlAttribs.src;

// Update the image URL so the images can be accessed in a dev envrionment
// URLs do not need to be changed in production
if (!Config.IS_IN_PRODUCTION) {
const devURL = Config.EXPENSIFY.NGROK_URL || Config.EXPENSIFY.SITE_ROOT;
previewSource = previewSource.replace(Config.EXPENSIFY.SITE_ROOT, devURL);
source = source.replace(Config.EXPENSIFY.SITE_ROOT, devURL);
previewSource = previewSource.replace(
Config.EXPENSIFY.DEFAULT_SITE_ROOT,
Config.EXPENSIFY.SITE_ROOT
);
source = source.replace(Config.EXPENSIFY.DEFAULT_SITE_ROOT, Config.EXPENSIFY.SITE_ROOT);
}

return (
Expand Down
1 change: 1 addition & 0 deletions tests/unit/mocks/react-native-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default {
PUSHER_APP_KEY: 'ac6d22b891daae55283a',
PUSHER_AUTH_URL: 'https://www.expensify.com.dev',
NGROK_URL: '',
USE_NGROK: false,
PARTNER_USER_ID: '',
PARTNER_USER_SECRET: ''
};

0 comments on commit 6f56f04

Please sign in to comment.