Passing return value of a function to target errors out #573
Unanswered
Napster158
asked this question in
Q&A
Replies: 1 comment
-
@Napster158 , I found the reason. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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?
Beta Was this translation helpful? Give feedback.
All reactions