Skip to content
This repository was archived by the owner on Nov 19, 2023. It is now read-only.

Commit b3d8459

Browse files
committed
refactor(toxy): use default generic proxy options that forward origin header
1 parent 02a3812 commit b3d8459

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/proxy.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,21 @@ module.exports = rocky.Rocky
99
* Extends Rocky Base prototype chain with
1010
* Toxy domain specific convenient methods.
1111
*
12-
* @class RockyBase
12+
* @param {Object} opts
13+
* @class ToxyProxy
14+
* @extends rocky.Rocky
15+
*/
16+
17+
/**
18+
* Alias to rocky.Base class.
1319
*/
1420

1521
const RockyBase = rocky.Base
1622

23+
/**
24+
* Proxy prototype methods
25+
*/
26+
1727
RockyBase.prototype.rule =
1828
RockyBase.prototype.filter = Directive.prototype.rule
1929

lib/toxy.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ module.exports = Toxy
1616

1717
function Toxy (opts) {
1818
if (!(this instanceof Toxy)) return new Toxy(opts)
19+
20+
opts = Object.assign(Toxy.defaults, opts)
1921
Proxy.call(this, opts)
2022

2123
this.routes = []
@@ -26,6 +28,15 @@ function Toxy (opts) {
2628
setupMiddleware(this)
2729
}
2830

31+
/**
32+
* Defines default rocky proxy options.
33+
*
34+
* @property {Object} defaults
35+
* @static
36+
*/
37+
38+
Toxy.defaults = { changeOrigin: true }
39+
2940
/**
3041
* Default TCP port to listen.
3142
*

0 commit comments

Comments
 (0)