gateway crashes when using rewrite plugin
Closed this issue · 1 comments
canhoviet-zz commented
Hi,
This issue is related to #3 which was closed.
I'm using express-gateway 1.7.2. After installing express-gateway-plugin-rewrite(1.1.1) using command:
"eg plugin install express-gateway-plugin-rewrite", I configured "gateway.config.yml" as:
policies:
- rewrite:
- condition:
name: regexpmatch
match: ^/auth/(.*)$
- action:
rewrite: /$1
Starting the gateway, it crashed with following error:
warn: [EG:gateway] rewrite plugin hasn't provided a schema. Validation for this plugin will be skipped.
/Users/canho/projects/tmp/gridly-gw/node_modules/express-gateway-plugin-rewrite/node_modules/path-to-regexp/index.js:105
if (path || index < str.length) {
^
TypeError: Cannot read property 'length' of undefined
at parse (/Users/canho/projects/tmp/gridly-gw/node_modules/express-gateway-plugin-rewrite/node_modules/path-to-regexp/index.js:105:26)
at Function.compile (/Users/canho/projects/tmp/gridly-gw/node_modules/express-gateway-plugin-rewrite/node_modules/path-to-regexp/index.js:120:27)
at policy (/Users/canho/projects/tmp/gridly-gw/node_modules/express-gateway-plugin-rewrite/manifest.js:31:42)
at policy.policy.args (/Users/canho/projects/tmp/gridly-gw/node_modules/express-gateway/lib/policies/index.js:30:16)
at pipelinePoliciesConfig.forEach.policyConfig (/Users/canho/projects/tmp/gridly-gw/node_modules/express-gateway/lib/gateway/pipelines.js:134:32)
at Array.forEach (native)
Is the configuration invalid & the gateway unable to validate it due to missing schema ?
XVincentX commented
Hey,
condition
and action
must be objects of the same array element, so you might want to remove the -
sign on the action
part.
Once removed, the policy should be working correctly. I should enforce the schema a bit and make sure you do not get such trouble. Hopefully I'll be able to issue an update soon.