Last active
March 31, 2021 16:27
-
-
Save greenrhyno/018042999a0deab501529224764c0fa4 to your computer and use it in GitHub Desktop.
Simple Proxy for Use of Local Tesseract Instance with Canon Development Server
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
/* | |
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