Closed danielegli closed 7 years ago
This module is intended to be run on the server side on a fixed IP. However, you can try out https://github.com/CaptEmulation/coc-api-proxy for a dedicated CoC API proxy
Waw captemulation you are fast on replay My compliments sir
Il giorno 19 mag 2017, alle ore 22:44, John Dean notifications@github.com ha scritto:
This module is intended to be run on the server side on a fixed IP. However, you can try out https://github.com/CaptEmulation/coc-api-proxy for a dedicated CoC API proxy
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
Thanks. Going to close this issue. Raise an issue at https://github.com/CaptEmulation/coc-api-proxy/issues if you have any problems
Yes, very quick indeed. Okay, thanks for the link and the work on this one (it was easy to use and worked well minus the proxy bit)
You were able to run this module in the browser? I actually never tried that.
I was running a local express server and using the API on my backend to get clan data. I wanted to deploy to a free heroku dyno for small clan usage, but the heroku dyno changes IPs constantly so my token is always invalidated. There are proxy addons in heroku but I need a way to set the proxy option for the coc request. I'm not terribly familiar with the http requests in node, but I think I'll have to rip apart the code a bit and try to get the proxy option working (or just rewrite my own requests I guess)
ah OK. This is an known problem with the Clash of Clans API. They (Supercell) require a fixed static IP.
I think I stumbled onto a quick and easy solution. You're using request-promise, built off http which respects the HTTP_PROXY env variable. Therefore this line of code:
process.env['HTTP_PROXY'] = process.env.QUOTAGUARDSTATIC_URL;
solves the problem and routes my app's outbound requests through the heroku addon proxy.
nice! Going to reopen this to add some text to the readme to cover this. PRs accepted
Hmm, I'm not sure how that constructor works exactly sorry. I imagine the best solution though would be to add another option to clashApi and then set it inside that constructor though.
Check out v0.4.0
of this module which includes a new request
option for setting request options.
Nice work and thanks. My little side project is chugging away nicely now
import clashApi from 'clash-of-clans-api';
let client = clashApi({
token: myToken,
request: {
proxy: process.env.QUOTAGUARDSTATIC_URL,
},
});
See request options for the full list of supported request options
danielegli, thank you so much, that simple fix was all that was needed to fix my two month long problem. Hats off to you sir!
:) happy building
Good luck with your application :-)
Question @PrittSpadeLord-- did you use the HTTP_PROXY
env var or the request: { proxy: } }
option to resolve your issue? Just wondering if the latter option works correctly.
@CaptEmulation Sorry for the extreme delay in responding, I had used:
process.env['HTTP_PROXY'] = process.env.QUOTAGUARDSTATIC_URL;
No problem :+1: Thanks!
Since the coc API is IP restricted per token, it would be nice to have a proxy option for the web calls so that I could use a third-party service to run my calls through.