0

I have the following gateway.config.yml file

http:
  port: 8080
admin:
  port: 9876
apiEndpoints:
  lags:
    path: '/lags/*'
serviceEndpoints:
  lags:
    url: 'http://lags:50001'
policies:
  - response-transformer
  - basic-auth
  - cors
  - expression
  - jwt
  - log
  - oauth2
  - proxy
  - rate-limit
  - verify-auth0-jwt
pipelines:
  lags:
    apiEndpoints:
      - lags
    policies:
      - log:
        - action:
            message: ${req.ip} ${req.method} ${req.originalUrl}
      - rate-limit:
        - action:
            max: 1
            windowMs: 1000
      - jwt:
        - action:
            secretOrPublicKeyFile: ./key/pubKey.pem
            checkCredentialExistence: false
      - response-transformer:
        - action:
            headers:
              add:
                content-type: "'application/json'"
      - verify-auth0-jwt:
        - action:
      - proxy:
        - action:
            serviceEndpoint: lags
            changeOrigin: true

When I run it, I get this error

api-gateway_1  | error: [EG:policy] Could not find policy response-transformer, Please make sure the plugins providing such policy
api-gateway_1  |        is correctly configured in system.config file.
api-gateway_1  | /app/node_modules/express-gateway/lib/policies/index.js:46
api-gateway_1  |       throw new Error('POLICY_NOT_FOUND');
api-gateway_1  |       ^
api-gateway_1  | 
api-gateway_1  | Error: POLICY_NOT_FOUND
api-gateway_1  |     at Policies.resolve (/app/node_modules/express-gateway/lib/policies/index.js:46:13)
api-gateway_1  |     at /app/node_modules/express-gateway/lib/gateway/index.js:72:29
api-gateway_1  |     at Array.forEach (<anonymous>)
api-gateway_1  |     at bootstrap (/app/node_modules/express-gateway/lib/gateway/index.js:71:66)
api-gateway_1  |     at module.exports (/app/node_modules/express-gateway/lib/gateway/index.js:20:39)
api-gateway_1  |     at Main.run (/app/node_modules/express-gateway/lib/index.js:23:43)
api-gateway_1  |     at Object.<anonymous> (/app/server.js:6:4)
api-gateway_1  |     at Module._compile (node:internal/modules/cjs/loader:1101:14)
api-gateway_1  |     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
api-gateway_1  |     at Module.load (node:internal/modules/cjs/loader:981:32)
api-gateway_1  |     at Function.Module._load (node:internal/modules/cjs/loader:822:12)
api-gateway_1  |     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
api-gateway_1  |     at node:internal/main/run_main_module:17:47

It is running in a docker container. I have the latest version of express-gateway defined in my package.json.

Please see below

{
  "name": "loc8r-api-gateway",
  "description": "Express Gateway Instance Bootstraped from Command Line",
  "repository": {},
  "license": "UNLICENSED",
  "version": "1.0.0",
  "main": "server.js",
  "dependencies": {
    "express-gateway": "^1.16.11",
    "express-jwt": "^6.0.0",
    "express-jwt-authz": "^2.4.1",
    "jsonwebtoken": "^8.5.1",
    "jwks-rsa": "^2.0.4"
  }
}
James McLeod
  • 2,381
  • 1
  • 17
  • 19
NduJay
  • 760
  • 1
  • 10
  • 23
  • 1
    Are you using the official Express Gateway docker container, or did you "roll your own?" If the latter, can you provide your Dockerfile? The error I see is with "verify-auth-jwt," not with "response-transformer." – James McLeod Aug 26 '21 at 10:45
  • 1
    I fixed it by using the official image. didn't know it existed. I was just using a node image and installing dependencies before. Thanks – NduJay Aug 28 '21 at 20:08

0 Answers0