From 7c5601109ae170cacb8b0df936c97e4006adbb03 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 14 Apr 2017 19:56:41 -0700 Subject: server refactor and jwt auth --- blockcypher.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 blockcypher.js (limited to 'blockcypher.js') diff --git a/blockcypher.js b/blockcypher.js new file mode 100644 index 00000000..91adbc10 --- /dev/null +++ b/blockcypher.js @@ -0,0 +1,17 @@ +const proxyMiddleware = require('http-proxy-middleware') +const proxyContext = '/blockcypher' + +const proxyOptions = { + target: 'https://api.blockcypher.com', + changeOrigin: true, + pathRewrite: { + '^/blockcypher/': '/' + }, + onProxyReq: function(proxyReq, req, res) { + var symbol + symbol = indexOf.call(proxyReq.path, '?') >= 0 ? '&' : '?' + return proxyReq.path += symbol + "token=" + config.blockcypher_token + } +} + +module.exports = proxyMiddleware(proxyContext, proxyOptions) -- cgit v1.2.3