fuzziebrain / suez

Configurable reverse proxy server to access external APIs from within Oracle Application Express, without needing to deal with common SSL certificate issues. IMPORTANT: Recommended for development use only!
MIT License
11 stars 3 forks source link

Better error handling with unknown domain #6

Open martindsouza opened 6 years ago

martindsouza commented 6 years ago

Supposed doesnotexist.somedomain.com is not registered in settings.json. If I call SUEZ for doesnotexist.localhost it'll give the following error:

TypeError: Cannot read property 'proxyTarget' of undefined
    at router (/app/suez/app.js:33:8)
    at Object.getTarget (/app/suez/node_modules/http-proxy-middleware/lib/router.js:15:21)
    at __applyRouter (/app/suez/node_modules/http-proxy-middleware/lib/index.js:118:32)
    at prepareProxyRequest (/app/suez/node_modules/http-proxy-middleware/lib/index.js:101:9)
    at middleware (/app/suez/node_modules/http-proxy-middleware/lib/index.js:40:38)
    at Layer.handle [as handle_request] (/app/suez/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/app/suez/node_modules/express/lib/router/index.js:317:13)
    at /app/suez/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/app/suez/node_modules/express/lib/router/index.js:335:12)
    at next (/app/suez/node_modules/express/lib/router/index.js:275:10)

I think we should have a more user friendly error if proxyTarget is not found to let developers know quickly that they either entered a bad name or need to add their target to settings.json