-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[No QA] Fix desktop CORS issue when using web proxy #7693
Conversation
No need to CP this – it only affects dev (specifically dev w/ web proxy) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
if (ELECTRON_ENVIRONMENT.isDev()) { | ||
const dotenv = require('dotenv'); | ||
const path = require('path'); | ||
const devEnvConfig = dotenv.config({path: path.resolve(__dirname, '../.env')}).parsed; | ||
|
||
if (devEnvConfig.USE_WEB_PROXY === 'true') { | ||
browserWindow.webContents.session.webRequest.onHeadersReceived(validDestinationFilters, (details, callback) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just tested this now and the app crashes / stays on white screen
This block fails with:
[Main] 04:19:38.521 › (node:97605) UnhandledPromiseRejectionWarning: TypeError: Cannot read properties of undefined (reading 'USE_WEB_PROXY')
[Main] at /Users/kidroca/Desktop/Freelance/Expensify.cash/desktop/main.js:186:34
External contributors are instructed not to have .env
files - zero config
The proxy.js
script actually checks for explicitly having USE_WEB_PROXY
set to false
- it always starts the server otherwise
Lines 3 to 8 in 394c301
require('dotenv').config(); | |
if (process.env.USE_WEB_PROXY === 'false') { | |
process.stdout.write('Skipping proxy as USE_WEB_PROXY was set to false.\n'); | |
process.exit(); | |
} |
I think we should do the same thing here - run the logic unless this value exists and it's false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another way is maybe PING the proxy server if it responds then it's running - use it, otherwise do nothing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should do the same thing here - run the logic unless this value exists and it's false
This sounds correct! This was reported in Slack today and I meant to fix it but unfortunately did not get around to it. Feel free to submit a PR if you don't want to wait until Monday.
🚀 Deployed to staging by @roryabraham in version: 1.1.39-0 🚀
|
Details
This fixes CORS in a way that's similar to #7665, but specifically for local development using the web proxy.
Fixed Issues
$ n/a – coming from multiple reports in slack:
Tests
.env
file,USE_NRGOK
isfalse
andUSE_WEB_PROXY
istrue
.npm run desktop
Tested On
Screenshots
Desktop
No CORS errors: