Skip to content
This repository was archived by the owner on Oct 15, 2022. It is now read-only.

Commit 1db731d

Browse files
author
Jonathan Ling
committed
Update decodeURI stuff for GET and add launch.json.
1 parent f9ffa75 commit 1db731d

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

.vscode/launch.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
8+
{
9+
"type": "node",
10+
"request": "launch",
11+
"name": "Launch Program",
12+
"program": "${workspaceFolder}\\app.js"
13+
}
14+
]
15+
}

app.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ if (!process.env.WHITELIST) {
2020
app.use(cors(corsOptions))
2121
}
2222

23-
app.use(bodyParser.json())
23+
app.use(bodyParser.urlencoded({
24+
extended: true
25+
}))
2426

2527
app.post('/:appName', mWare.addHeaders, mWare.getResponse)
2628

middleware.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ addHeaders = function(req, res, next) {
1919
req.container.headers[`${process.env[variable + '_KEY']}`] = process.env[`${variable}_VALUE`]
2020
}
2121

22-
req.apiUrl = process.env[`${req.params.appName}_URL`] || req.body.apiUrl || false
22+
req.apiUrl = process.env[`${req.params.appName}_URL`] || decodeURI(JSON.parse(req.body.apiUrl)) || false
2323

2424
if (req.container.headers['']) {
2525
res.json({
@@ -54,7 +54,7 @@ addHeaders = function(req, res, next) {
5454
}
5555

5656
getResponse = function(req, res, next) {
57-
console.log(req.container.headers, req.body)
57+
//console.log(req.apiUrl)
5858
let reqConfig = {
5959
url: req.apiUrl,
6060
headers: req.container.headers,
@@ -79,4 +79,4 @@ getResponse = function(req, res, next) {
7979
module.exports = middleware = {
8080
addHeaders,
8181
getResponse
82-
}
82+
}

0 commit comments

Comments
 (0)