Http-proxy-middleware: Is there a async router function?

Created on 24 Dec 2019  路  3Comments  路  Source: chimurai/http-proxy-middleware

Question

I want to dynamically change target for proxy, router options as a function seems to be a good choice, but it's a sync function returns a target string.

Is there a way to do the async router function, something like this

async function asyncRouterFunc(req) {
    const target = await getNewTargetBasedOnReq(req);
    return target;
}

Most helpful comment

Just merged this in PR #379

I released a beta version:
npm install [email protected]

Let me know if you run into issues.

All 3 comments

Just merged this in PR #379

I released a beta version:
npm install [email protected]

Let me know if you run into issues.

@chimurai it works like a charm. Thanks!

published: [email protected] with async router support

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SidneyNemzer picture SidneyNemzer  路  5Comments

DylanPiercey picture DylanPiercey  路  6Comments

villesau picture villesau  路  8Comments

ubreddy picture ubreddy  路  5Comments

minhduchcm picture minhduchcm  路  7Comments