alibaba / alibaba/anyproxy

Anyproxy is not working on localhost

Open
#514 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.9k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

I run `anyproxy --port 9999 --intercept --rule ./rules.js`, and have the SwitchyOmega running.
It intercept the API response in Staging site. But is not working in localhost.
Do I need to configure something to make it run on localhost?

My rules.js is something like this.
```
module.exports = {
*beforeSendResponse(requestDetail, responseDetail) {
require.cache = {};

if (
/favorites/.test(requestDetail.url) &&
requestDetail.requestOptions.method == "GET"
) {
const response = responseDetail.response;
const mock = require("./data/favorites");
response.body = JSON.stringify(mock);
return { response };
}
}
};
```

#### Which platform are you running AnyProxy

Mac

#### The version of the AnyProxy

4.1.0

#### Your expected behavior of AnyProxy

Anyproxy can intercept API response on localhost.

#### The actual behavior of AnyProxy

Anyproxy doesn't catch anything from localhost request.

#### The log of the error

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the `anyproxy --port 9999 --intercept --rule ./rules.js` command and the `beforeSendResponse` hook in `rules.js`; compare how staging and localhost requests reach the proxy. Done means the localhost API response is intercepted and the configured mock response is returned.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.