diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..35b4d37 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "program": "${workspaceFolder}\\app.js" + } + ] +} diff --git a/app.js b/app.js index d935fbf..8fe343d 100644 --- a/app.js +++ b/app.js @@ -20,7 +20,9 @@ if (!process.env.WHITELIST) { app.use(cors(corsOptions)) } -app.use(bodyParser.json()) +app.use(bodyParser.urlencoded({ + extended: true +})) app.post('/:appName', mWare.addHeaders, mWare.getResponse) diff --git a/middleware.js b/middleware.js index afa3c0e..01f9bf7 100644 --- a/middleware.js +++ b/middleware.js @@ -19,7 +19,7 @@ addHeaders = function(req, res, next) { req.container.headers[`${process.env[variable + '_KEY']}`] = process.env[`${variable}_VALUE`] } - req.apiUrl = process.env[`${req.params.appName}_URL`] || req.body.apiUrl || false + req.apiUrl = process.env[`${req.params.appName}_URL`] || decodeURI(JSON.parse(req.body.apiUrl)) || false if (req.container.headers['']) { res.json({ @@ -54,7 +54,7 @@ addHeaders = function(req, res, next) { } getResponse = function(req, res, next) { - console.log(req.container.headers, req.body) + //console.log(req.apiUrl) let reqConfig = { url: req.apiUrl, headers: req.container.headers, @@ -79,4 +79,4 @@ getResponse = function(req, res, next) { module.exports = middleware = { addHeaders, getResponse -} \ No newline at end of file +}