1
0
mirror of https://github.com/oceanprotocol/webtasks synced 2024-06-30 05:32:04 +02: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 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/', target: 'https://www.zohoapis.com/crm/v2/',
pathRewrite: { '^/zoho/crm/': '/' },
changeOrigin: true, changeOrigin: true,
headers: { onProxyReq
Authorization: 'Zoho-oauthtoken hello' }
}
const configZohoCampaigns = {
target: 'https://campaigns.zoho.com/api/',
pathRewrite: { '^/zoho/campaigns/': '/' },
changeOrigin: true,
onProxyReq
} }
server.use(cors()) 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) server.listen(4430)