2021-09-09 11:33:20 -07:00
|
|
|
const logInFilter = function (pathname, req) {
|
|
|
|
return pathname.match('^/logIn') && req.method === 'POST';
|
|
|
|
};
|
|
|
|
|
2021-07-17 04:56:50 +10:00
|
|
|
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',
|
2021-09-09 11:33:20 -07:00
|
|
|
createProxyMiddleware(logInFilter, {
|
2021-07-17 04:56:50 +10:00
|
|
|
target: 'http://localhost:9002',
|
|
|
|
changeOrigin: true,
|
|
|
|
}),
|
|
|
|
);
|
2021-09-02 19:05:13 -07:00
|
|
|
app.use(
|
|
|
|
'/authenticate',
|
|
|
|
createProxyMiddleware({
|
|
|
|
target: 'http://localhost:9002',
|
|
|
|
changeOrigin: true,
|
|
|
|
}),
|
|
|
|
);
|
2021-07-17 04:56:50 +10:00
|
|
|
app.use(
|
|
|
|
'/api/v2/graphql',
|
|
|
|
createProxyMiddleware({
|
|
|
|
target: 'http://localhost:9002',
|
|
|
|
changeOrigin: true,
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
};
|
|
|
|
}
|