Skip to content

sixwinds/fe-dev-proxy-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fe-dev-proxy-server

Frontend development proxy server

Usage

http://localhost/api/v1/user -> http://api.server.com/api/v1/user

let DevServer = require( 'fe-dev-proxy-server' );

let config = {
  routes: [
    {
      url: '/api/v1/user',
      target: 'http://api.server.com/api/v1/user'
    }
  ]
}

let server = new DevServer( config );
server.listen( 80 );

http://localhost/api/** -> http://api.server.com/api/{all api url}

let DevServer = require( 'fe-dev-proxy-server' );

let config = {
  routes: [
    {
      url: /\/api\/(.*)/,
      target: 'http://api.server.com/api/[path]'
    }
    // or 
    // {
    //   url: /\/(api\/.*)/,
    //   target: 'http://api.server.com/[path]'
    // }
  ]
}

let server = new DevServer( config );
server.listen( 80 );

http://localhost/static/js/index.js -> D:\tmp\resources\js\index.js

let DevServer = require( 'fe-dev-proxy-server' );

let config = {
  routes: [
    {
      url: '/static/js/index.js',
      target: 'D:\tmp\resources\js\index.js',
      static: true
    }
  ]
}

let server = new DevServer( config );
server.listen( 80 );

http://localhost/static/** -> './resources/{all static resource}'

let DevServer = require( 'fe-dev-proxy-server' );

let config = {
  routes: [
    {
      url: /\/static\/(.*)/,
      target: './resources/[path]', // relative path to current folder running this proxy server
      static: true
    }
  ]
}

let server = new DevServer( config );
server.listen( 80 );

About

Frontend development proxy server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published