-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Prevents JS Debugger issues with CORS #17720
Changes from 2 commits
24c3c78
23217a8
acdb88c
5dfbcca
977f7f2
ca28ffe
501edf6
aa1d00d
3c7c4cc
ec8b69e
c117098
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,8 +14,8 @@ const launchChrome = require('../util/launchChrome'); | |
|
||
const {exec} = require('child_process'); | ||
|
||
function launchChromeDevTools(port, args = '') { | ||
var debuggerURL = 'http://localhost:' + port + '/debugger-ui' + args; | ||
function launchChromeDevTools(host, args = '') { | ||
var debuggerURL = 'http://' + host + '/debugger-ui' + args; | ||
console.log('Launching Dev Tools...'); | ||
launchChrome(debuggerURL); | ||
} | ||
|
@@ -25,7 +25,7 @@ function escapePath(pathname) { | |
return '"' + pathname + '"'; | ||
} | ||
|
||
function launchDevTools({port, projectRoots}, isChromeConnected) { | ||
function launchDevTools({host, projectRoots}, isChromeConnected) { | ||
// Explicit config always wins | ||
var customDebugger = process.env.REACT_DEBUGGER; | ||
if (customDebugger) { | ||
|
@@ -39,12 +39,13 @@ function launchDevTools({port, projectRoots}, isChromeConnected) { | |
}); | ||
} else if (!isChromeConnected()) { | ||
// Dev tools are not yet open; we need to open a session | ||
launchChromeDevTools(port); | ||
launchChromeDevTools(host); | ||
} | ||
} | ||
|
||
module.exports = function(options, isChromeConnected) { | ||
return function(req, res, next) { | ||
var host = req.headers.host; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Later it might be nice to honor the protocol too (ex: setting up an HTTPS reverse proxy in front of the packager server) and to use something like Express’s approach to inferring the protocol: https://github.com/expressjs/express/blob/master/lib/request.js#L306 |
||
if (req.url === '/launch-safari-devtools') { | ||
// TODO: remove `console.log` and dev tools binary | ||
console.log( | ||
|
@@ -62,7 +63,7 @@ module.exports = function(options, isChromeConnected) { | |
launchDevTools(options, isChromeConnected); | ||
res.end('OK'); | ||
} else if (req.url === '/launch-js-devtools') { | ||
launchDevTools(options, isChromeConnected); | ||
launchDevTools(host, options, isChromeConnected); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think maybe here should be
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR works here after this modify. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right. Messed up the copy pasta |
||
res.end('OK'); | ||
} else { | ||
next(); | ||
|
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.
Why eslint does not throw error when using "var" ?
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.
There are still a lot of files that are not converted to es6 so the rule is not enabled.