Skip to content

Instantly share code, notes, and snippets.

@kzlsakal
Last active August 25, 2020 06:38
Show Gist options
  • Save kzlsakal/27544105d8f5d6215871701c70c5c5af to your computer and use it in GitHub Desktop.
Save kzlsakal/27544105d8f5d6215871701c70c5c5af to your computer and use it in GitHub Desktop.
Use redirect instead of proxy
// Replace app.use('*/photo/api/*', createProxyMiddleware(photoProxy)); with
app.get('/photo/api/*', (req, res, next) => res.redirect(photoTarget + req.originalUrl.replace(/\?.*$/, '')));
// Replace app.use('*/sb/api/*', createProxyMiddleware(sbProxy)); with
app.get('/sb/api/*', (req, res, next) => res.redirect(sbTarget + req.originalUrl.replace(/\?.*$/, '')));
// Replace app.use('*/reviews/api/*', createProxyMiddleware(reviewsProxy)); with
app.get('/reviews/api/*', (req, res, next) => res.redirect(reviewsTarget + req.originalUrl.replace(/\?.*$/, '')));
// Replace app.use('*/sln/api/*', createProxyMiddleware(slnProxy)); with
app.get('/sln/api/*', (req, res, next) => res.redirect(slnTarget + req.originalUrl.replace(/\?.*$/, '')));
@kzlsakal
Copy link
Author

kzlsakal commented Aug 21, 2020

If the security group settings and ports are not properly set up for your proxy server or one of the services, you may receive a 504 Gateway Timeout or an ECONNREFUSED error in your proxy. You may follow the instructions in this file to use redirection instead of proxy in your server/index.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment