mirror of
https://github.com/datahub-project/datahub.git
synced 2025-07-20 16:10:24 +00:00
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
const logInFilter = function (pathname, req) {
|
|
return pathname.match('^/logIn') && req.method === 'POST';
|
|
};
|
|
|
|
if (process.env.REACT_APP_MOCK === 'true' || process.env.REACT_APP_MOCK === 'cy') {
|
|
// no proxy needed, MirageJS will intercept all http requests
|
|
module.exports = function () {};
|
|
} else {
|
|
// create a proxy to the graphql server running in docker container
|
|
const { createProxyMiddleware } = require('http-proxy-middleware');
|
|
|
|
module.exports = function (app) {
|
|
app.use(
|
|
'/logIn',
|
|
createProxyMiddleware(logInFilter, {
|
|
target: 'http://localhost:9002',
|
|
changeOrigin: true,
|
|
}),
|
|
);
|
|
app.use(
|
|
'/authenticate',
|
|
createProxyMiddleware({
|
|
target: 'http://localhost:9002',
|
|
changeOrigin: true,
|
|
}),
|
|
);
|
|
app.use(
|
|
'/api/v2/graphql',
|
|
createProxyMiddleware({
|
|
target: 'http://localhost:9002',
|
|
changeOrigin: true,
|
|
}),
|
|
);
|
|
};
|
|
}
|