development-proxy

proxy your remote server for your web development. mock resources if you create some new features. cache server requests for developing offline

Usage no npm install needed!

<script type="module">
  import developmentProxy from 'https://cdn.skypack.dev/development-proxy';
</script>

README

npm npm Dependency Status devDependency Status

development-proxy

install

npm install development-proxy -S

proxy your remote server for your web development mock resources if you create some new features cache server requests for developing offline

USAGE

const path = require('path');
const chalk = require('chalk');
const http = require('http');
const proxy = require('development-proxy');

const proxyPort = 3003;
const cacheDir = path.resolve(__dirname, '../.tmp/proxy-cache');

const config = {
  api: {
    local: `http://localhost:${proxyPort}/-api-/`,
    remote: 'http://dev.example.com/',
    cacheOfflineOnly: true,
    cacheDir
  },
  dq: {
    local: `http://localhost:${proxyPort}/-dq-/`,
    remote: 'http://dq.example.com/',
    cacheOfflineOnly: true,
    cacheDir
  },
  assets: {
    local: `http://localhost:${proxyPort}/-assets-/`,
    remote: 'http://example.s3.amazonaws.com/',
    cacheOfflineOnly: false,
    cacheDir
  }
};

const server = proxy([
  config.api,
  config.dq,
  config.assets
]);

http.createServer(server).listen(proxyPort);

console.log('PROXY run at', chalk.cyan(`http://localhost:${proxyPort}`)); // eslint-disable-line no-console