Is there a way to proxy ajax requests to another server in phanomjs?
I'm using webpack server for development with proxyng '/api/**' requests to my local backend server http://myserver.dev. For prependering I use phantomjs but it return 404 for my ajax requests.
If I making ajax manually to http://myserver.dev/api/** then it works perfectly, but i wannna keep my services clean if it's possible.
I found the answer. It is possible with onResourceRequested callback.
page.onResourceRequested = function (requestData, request) {
if (/^http:\/\/localhost:8000\/api/i.test(requestData.url)) {
request.changeUrl(
requestData.url.replace('http://localhost:8000', 'http://myserver.dev')
);
}
}