用charles抓取請求的時候默勾,charles總是抓不到localhost:3000發(fā)出的請求,也就沒辦法模擬數(shù)據(jù),
官網(wǎng)說什么要在charles模擬本地數(shù)據(jù)的時候域名用localhost_charlesproxy_com。(_&.)
然而很不幸的是,我本地localhost_charlesproxy_com::3000本啟動不起來項目使套,所以只能修改react項目的默認域名,在react項目的package.json文件中將原來的"start": “react-scripts start”, 這一句改為"set PORT=3000 HOST=localhost_charlesproxy_com && react-scripts start"咐蚯,項目的本地啟動地址就變成了了localhost_charlesproxy_com::3000童漩。此時再用charles模擬數(shù)據(jù)就成功了。
[charles開啟Charles-Proxy-macOS Proxy 時報錯]
Charles cannot configure your proxy settings while it is on a read-only volume. Perhaps you are running Charles from the disk image? If so, please copy Charles to the Applications folder and run it again. Otherwise please ensure that Charles is writable by the current user and try again.
解決:
終端輸入后重啟
sudo chown -R root "/Applications/Charles.app/Contents/Resources"
sudo chmod -R u+s "/Applications/Charles.app/Contents/Resources"