-
Notifications
You must be signed in to change notification settings - Fork 878
Description
Instead of a hardcoded string, when I pass a variable to the target option. It errors out.
My below function works, when the target is a harcoded url
const proxyMiddleware = proxy({
target: 'example.com',
changeOrigin: true,
pathRewrite: rewritePath,
});
When I pass a value returned by a function to target, it fails, errors out.
const artifactoryHost = function (req, res) {
const artifactoryHost = req.artifactoryHost;
return artifactoryHost;
};
const proxyMiddleware = proxy({
target: 'artifactoryHost',
changeOrigin: true,
pathRewrite: rewritePath,
});
I further went ahead and tried the router option, as below:
const proxyMiddleware = proxy({
target: 'https://ubit-artifactory.com',
router: artifactoryHost,
changeOrigin: true,
pathRewrite: rewritePath,
});
But then I started seeing weird errors in my console:
Unhandled rejection TypeError: Cannot read property 'split' of null
Any help, appreciated!! Is there a workaround?