Github API and Access-Control-Allow-Origin

后端 未结 1 1771
情歌与酒
情歌与酒 2020-12-16 18:25

this probably is a simple (series of) question(s) but I can\'t wrap my head around it.

I\'m trying to access the github api from a web app hosted on my site. This is

相关标签:
1条回答
  • 2020-12-16 19:04

    In order to get CORS working for your site (e.g. http://example.com), you have to enable it by creating a GitHub OAuth application here: https://github.com/settings/applications

    Since you are using a GitHub applications to get CORS to work (not using it for enabling OAuth itself), you can just enter your site's URL in all three fields in the "Create Application form":

    • Name: http://example.com
    • URL: http://example.com
    • Callback URL: http://example.com

    Note that if you intend to use OAuth functionality, you need to setup Callback URL differently.

    After this, you should be able to send AJAX requests to GitHub APIs from your site http://example.com.

    0 讨论(0)
提交回复
热议问题