Skip to content

Commit

Permalink
Switch proxy to correct host when on staging
Browse files Browse the repository at this point in the history
  • Loading branch information
marcaaron committed May 6, 2021
1 parent 7a7fd7d commit e0ccdbe
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions web/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ if (process.env.USE_WEB_PROXY === 'false') {
process.exit();
}

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)) {
host = 'staging.expensify.com';
}

/**
* Local proxy server that hits the production endpoint
* to get around CORS issues. We use this so that it's
Expand All @@ -15,12 +22,12 @@ if (process.env.USE_WEB_PROXY === 'false') {
*/
const server = http.createServer((request, response) => {
const proxyRequest = https.request({
hostname: 'www.expensify.com',
hostname: host,
method: 'POST',
path: request.url,
headers: {
...request.headers,
host: 'www.expensify.com',
host,
},
port: 443,
});
Expand Down

0 comments on commit e0ccdbe

Please sign in to comment.