Skip to content

Instantly share code, notes, and snippets.

@mihail-petrov
Created May 10, 2022 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mihail-petrov/241df59182ca280349808b5e48ab55ab to your computer and use it in GitHub Desktop.
Save mihail-petrov/241df59182ca280349808b5e48ab55ab to your computer and use it in GitHub Desktop.
// *****
// 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