-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple rewrites not supported #39
Comments
Hi @tgrassl Cases like the above issue can happen enough, and I agree. In the above case, since To solve the above issue, in the next version, we plan to modify the Thanks 😄 |
@all-contributors please add @tgrassl for bug |
I've put up a pull request to add @tgrassl! 🎉 |
I just released a package. You can now use it like this(Pattern checks are run in the order they are entered into the array first.) // pages/[...all].ts
...
export default (req: NextApiRequest, res: NextApiResponse) => (
isDevelopment
? httpProxyMiddleware(req, res, {
// You can use the `http-proxy` option
target: 'https://www.example.com',
// In addition, you can use the `pathRewrite` option provided by `next-http-proxy-middleware`
pathRewrite: [{
patternStr: '^/api/new',
replaceStr: '/v2'
}, {
patternStr: '^/api',
replaceStr: ''
}],
})
: res.status(404).send(null)
); |
Hi,
There's an error in the rewritePath method. It already returns after the first replacement and thus never checks other rewrites.
Example:
Wrong: rewritePath('/api/test/xy/', { '/$': '', '^/api/test/': '' }) -> /api/test/xy
Correct: rewritePath('/api/test/xy/', { '/$': '', '^/api/test/': '' }) -> xy
possible fix:
The text was updated successfully, but these errors were encountered: