jmfridey / COC-Clan-Page

MIT License
6 stars 6 forks source link

No issue but really important question #1

Closed MarcoLeko closed 4 years ago

MarcoLeko commented 6 years ago

How did U managed to Develop locally with the Data by calling a http request? I mean to fetch the Data ur token is only valid with a PUBLIC IP. So when U start the App, the App is only available in your local Network.

jmfridey commented 6 years ago

Hi MarcoLeko, I hope I understand your question correctly with this answer. It sounds like you're trying to use this code local on your computer for development, if that's correct I can explain how I did it. I basically created a temporary API token with the public IP that my ISP provided. Simply by going to google and searching for "What's my IP" and using that IP while creating my token. Of course after I was ready to publish it to a website, I went ahead and created a new API token with my web servers public IP.

I hope that answers your question! Please let me know if I didn't understand your question completely and I'll try my best to clarify! Thanks!

MarcoLeko commented 6 years ago

Yeah You answered my question but your Strategy cant basically Work, cause i tried the same Strategy myself! Because when You start your Project with npm start or ng serve You start your application on your local server (on localhost:4200) that means that your application is only on your local Network reachable. So your token with your registered PUBLIC IP can Not Work when You try to make a http request to coc API. Please correct me, If You think i am Wrong!! :)

mateeni-dev commented 6 years ago

App access will be limited to local clients, when running on local network, which is not configured as a web server, but app can still access global API using both http and https. You just have to configure it to use correct token. As @jmfridey has "created a temporary API token with the public IP", app should work on local network.

MarcoLeko commented 6 years ago

OK! So i am currently working with angular 5 and the new HTTPClient service,and still throws me a

Failed to load https://api.clashofclans.com/v1/clans/%238Q80V2JG: Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers in preflight response.

Error. Only if i setup a proxy.conf.json with the target-url:https://api.clashofclans.com, it works! Really Appriciate the help of you. I wasnt getting any kind of "good" responses at stackoverflow and anywhere else, until i asked here! Cheers^^