Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion desktop/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ const mainWindow = (() => {
const path = require('path');
const devEnvConfig = dotenv.config({path: path.resolve(__dirname, '../.env')}).parsed;

if (devEnvConfig.USE_WEB_PROXY === 'true') {
if (devEnvConfig.USE_WEB_PROXY !== 'false') {
Comment on lines 184 to +186

@kidroca kidroca Feb 14, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, sorry you still have to have an .env file to make this work
When you don't have an .env file parsed - devEnvConfig is undefined and you get this error:

[Main] 14:10:46.010 › (node:8157) UnhandledPromiseRejectionWarning: TypeError: Cannot read properties of undefined (reading 'USE_WEB_PROXY')
[Main]     at /Users/kidroca/Desktop/Freelance/Expensify.cash/desktop/main.js:186:34

What the proxy script does is a bit more flexible and you don't need to import path

dotenv.config();

if (process.env.USE_WEB_PROXY !== 'false') ...

When you don't pass a path to dotenv it will use .env by default
If there is such a file the variables defined would be assigned to process.env

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops ... I encountered this locally and had committed but not pushed the fix 😞

browserWindow.webContents.session.webRequest.onHeadersReceived(validDestinationFilters, (details, callback) => {
// eslint-disable-next-line no-param-reassign
details.responseHeaders['access-control-allow-origin'] = ['http://localhost:8080'];
Expand Down