Created
May 10, 2022 12:27
-
-
Save mihail-petrov/241df59182ca280349808b5e48ab55ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ***** | |
// setupProxy.js | |
const { createProxyMiddleware } = require('http-proxy-middleware'); | |
module.exports = function(app) { | |
app.use('/api', createProxyMiddleware({ | |
target : 'http://localhost:3000', | |
changeOrigin : true, | |
})); | |
app.use('/oauth', createProxyMiddleware({ | |
target : 'https://auth.reltio.com', | |
changeOrigin : true, | |
})); | |
app.use('/reltio', createProxyMiddleware({ | |
target : 'https://test-usg.reltio.com/', | |
changeOrigin : true, | |
})); | |
}; | |
// ***** | |
// example | |
const handleSubmit = async () => { | |
const url = `/oauth/token?username=movses.karagyozyan&password=KfVwYtiaNQZFHD7&grant_type=password`; | |
const result = await fetch(url, { | |
headers : { | |
'Authorization' : 'Basic cmVsdGlvX3VpOm1ha2l0YQ==' | |
} | |
}); | |
const tokkenResult = await result.json(); | |
const accessToken = tokkenResult.access_token; | |
const requestUrl = `/reltio/permissions/44Po6oyqjrCGsOo`; | |
const configApiCall = await fetch(requestUrl, { | |
headers : { | |
'Content-Type' : 'application/json', | |
'Authorization' : `Bearer ${accessToken}` | |
}}); | |
const collection = await configApiCall.json(); | |
console.log(collection); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment