[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) |
|
✋ 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.
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:34External 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
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.
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.
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
.envfile,USE_NRGOKisfalseandUSE_WEB_PROXYistrue.npm run desktopTested On
Screenshots
Desktop
No CORS errors: