Skip to content

Instantly share code, notes, and snippets.

@lesonky
Last active May 16, 2021 13:14
Show Gist options
  • Save lesonky/0a76aadf00815f225eb710ffac7c664c to your computer and use it in GitHub Desktop.
Save lesonky/0a76aadf00815f225eb710ffac7c664c to your computer and use it in GitHub Desktop.
开发小技巧
  1. 解决 chromedriver 无法安装的问题
设置npm config set "chromedriver_cdnurl=http://cdn.npm.taobao.org/dist/chromedriver"
设置yarn config set "chromedriver_cdnurl" "https://npm.taobao.org/mirrors/chromedriver"
  1. 解决 poxyTable 翻墙问题
// https://github.com/ly525/blog/issues/312
问题
 I  Your application is running here: http://0.0.0.0:9527
[HPM] Error occurred while trying to proxy request /v1/api/queryReport from 0.0.0.0:1234 to http://www.abc.com/ (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
http://blog.epoos.com/2018/05/21/proxy-error/
http://blog.epoos.com/2018/05/21/proxy-error/
create-react-app
// dependencies: proxy-agent、http-proxy-middleware
// reference: https://medium.com/@Pavan_/set-up-proxy-to-work-with-multiple-apis-in-create-react-app-be595a713eb2
// location: project/src/setupProxy.js(if not exist, create it)
const ProxyAgent = require('proxy-agent')
const proxy = require('http-proxy-middleware')
const ProxyAgent = require('proxy-agent')
const proxy = require('http-proxy-middleware')
module.exports = function (app) {
    app.use(proxy('/api', {
        agent: new ProxyAgent('socks5://127.0.0.1:1086'),
        target: 'http://abc.com/',
        changeOrigin: true,
    }))
}
// vue cli2
// location: project/config/index.js
// dependencies: proxy-agent、
const ProxyAgent = require('proxy-agent')
proxyTable: {
      '/api': {
        agent: new ProxyAgent('socks5://127.0.0.1:1086'),
        target: 'http://abc.com/',
        changeOrigin: true,
   }  
},
// vue cli3
// location: project/vue.config.js
// dependencies: proxy-agent
const ProxyAgent = require('proxy-agent')
module.exports = {
  devServer: {
    proxy: {
      '/api': {
        agent: new ProxyAgent('socks5://127.0.0.1:1086'),
        target: 'http://api.com',
        changeOrigin: true,
      }
    }
  },
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment