Skip to content

Instantly share code, notes, and snippets.

@greenrhyno
Last active March 31, 2021 16: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 greenrhyno/018042999a0deab501529224764c0fa4 to your computer and use it in GitHub Desktop.
Save greenrhyno/018042999a0deab501529224764c0fa4 to your computer and use it in GitHub Desktop.
Simple Proxy for Use of Local Tesseract Instance with Canon Development Server
/*
To use in Canon app, add this file in /api/ folder and set your CANON_CMS_CUBES var to point to
your local tesseract instance (e.g. `http://localhost:7777`)
*/
const { createProxyMiddleware } = require('http-proxy-middleware');
const LOCALHOST_REGX = /^(?:http:\/\/)?localhost/;
module.exports = function(app) {
const {NODE_ENV, CANON_CMS_CUBES} = process.env;
if (NODE_ENV === 'development' &&
LOCALHOST_REGX.test(CANON_CMS_CUBES)) {
app.use('/tesseract', createProxyMiddleware({
target: process.env.CANON_CMS_CUBES,
changeOrigin: true,
pathRewrite: {
[`^/tesseract`]: '',
},
}));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment