Skip to content

Commit acc5855

Browse files
committed
supporting url rewrite
1 parent ef1b95d commit acc5855

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ const gateway = (opts) => {
9191

9292
const handler = (route, proxy, proxyHandler) => async (req, res, next) => {
9393
try {
94-
req.url = req.url.replace(route.prefix, route.prefixRewrite)
94+
req.url = route.urlRewrite
95+
? route.urlRewrite(req)
96+
: req.url.replace(route.prefix, route.prefixRewrite)
9597
const shouldAbortProxy = await route.hooks.onRequest(req, res)
9698
if (!shouldAbortProxy) {
9799
const proxyOpts = Object.assign({

0 commit comments

Comments
 (0)