1
0
mirror of https://github.com/oceanprotocol/webtasks synced 2024-11-24 02:55:13 +01:00

handle CRM & Campaigns API

This commit is contained in:
Matthias Kretschmann 2018-06-21 13:11:26 +02:00
parent d9946926fa
commit e0ddc2f3cf
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -5,16 +5,28 @@ const proxy = require('http-proxy-middleware')
const server = express()
const config = {
const onProxyReq = function (proxyReq, req) {
proxyReq.setHeader('Authorization', `Zoho-oauthtoken ${req.webtaskContext.secrets.ZOHO_TOKEN}`)
}
const configZohoCRM = {
target: 'https://www.zohoapis.com/crm/v2/',
pathRewrite: { '^/zoho/crm/': '/' },
changeOrigin: true,
headers: {
Authorization: 'Zoho-oauthtoken hello'
}
onProxyReq
}
const configZohoCampaigns = {
target: 'https://campaigns.zoho.com/api/',
pathRewrite: { '^/zoho/campaigns/': '/' },
changeOrigin: true,
onProxyReq
}
server.use(cors())
server.use('*', proxy(config))
// server.use('*', proxy(config))
server.use(proxy('/zoho/crm/**', configZohoCRM))
server.use(proxy('/zoho/campaigns/**', configZohoCampaigns))
server.listen(4430)