1.0.3 • Published 6 years ago

proxy-local v1.0.3

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

proxy-local

proxy static file to local, nonmatched url will through the proxy

Installation

npm i proxy-local --save-dev

Usage

1、start your server

const localProxy = require('proxy-local')

const httpRules = [
  {
    // http://www.tt.com/web/js/tt.js => /Users/path/to/file.js
    test: '**/*/web/**/*',      // can be node-glob or regexp
    async fn(remoteUrl) {       // should return a local path
      return '/Users/path/to/file.js'
    }
  }
]

const httpsRules = httpRules

const httpOptions = {
  port: '',             // http port, default 3000
  httpsPort: '',        // https port, default 3001, it must be same to the httpsOptions port
  rules: httpRules
}

const httpsOptions = {
  port: '',             // https port, default 3001
  rules: httpsRules
}

let httpServer = new localProxy.httpServer(httpOptions)
let httpsServer = new localProxy.httpsServer(httpsOptions)

httpServer.start()
httpsServer.start()

2、setup your browser proxy

const httpOptions = {
  autoSetProxy: true
}

const httpsOptions = {
    autoSetProxy: true
}
  • manual, change your browser proxy by yourself
    • http proxy port => httpOptions port
    • https proxy port => httpOptions port ( https should go the http server )

Note

if you need https local proxy, you also need to open chrome with ignore-certificate-error args

// windos
chrome --args --ignore-certificate-errors
// mac
open /Applications/Google\ Chrome.app --args --ignore-certificate-errors
1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago