1

I am making a service which is basically just a UI for another services api that only allows a specific number of requests to be made per machine for a certain period of time.

Because I would be making api requests for lots of people, I would quickly hit these limits, so to get around this I wanted to use JQuery to make the api calls on the client side, however because of javascripts same-origin policy this is proving to be quite difficult.

So I was wondering, would it be possible to create a server side proxy which routed api requests through the clients ip address? And if so, how could I go about implementing this? I've looked at things like node-http-proxy's proxy tables but I'm still unsure if it would work with the clients ip address.

asked Jul 30, 2013 at 21:28

2 Answers 2

1

Unfortunately you cannot "use the clients IP" as a source when routing through such a server proxy.

However you might be lucky if the service accepts an X-Forwarded-For HTTP Header. You can set that header in the proxy when sending the request to the service. The value of the header should be the clients IP.

Read more about X-Forwarded-For here: http://en.wikipedia.org/wiki/X-Forwarded-For

answered Jul 30, 2013 at 21:34
Sign up to request clarification or add additional context in comments.

Comments

1

As mentioned by @HallvarHelleseth you cannot do what you are wanting. However, if the service in question supports JSONP or CORS, you should be able to do what you are wanting direct from the client.

jQuery supports CORS and JSONP, if you are using that. The limitation is IE < 10 has a different model than other browsers in support of CORS. For those implementing API services meant to be widely available, I would suggest supporting both.

answered Jul 30, 2013 at 21:44

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.