在Golang的Krakend配置文件中配置外部URL,以便在Golang中进行Facebook连接

问题描述

我的问题是关于开源网关“ KrakenD”的。

我已经设置了一个配置文件,除了通过Facebook进行连接外,该配置文件对我进行的每条路由都适用。

{
    "version": 2,"extra_config": {},"timeout": "3000ms","cache_ttl": "300s","output_encoding": "json","name": "xxxxxx-gateway","endpoints": [
    {
      "endpoint": "/register","method": "POST","backend": [
        {
          "url_pattern": "/register","encoding": "json","sd": "static","host": [
            "http://xxxxxx-auth-service"
          ],"disable_host_sanitize": false
        }
      ]
    },{
      "endpoint": "/login","backend": [
        {
          "url_pattern": "/login",{
      "endpoint": "/facebook/login","method": "GET","backend": [
        {
          "url_pattern": "/facebook/login",{
      "endpoint": "/facebook/callback","backend": [
        {
          "url_pattern": "/facebook/callback",{
      "endpoint": "/logout","backend": [
        {
          "url_pattern": "/logout","disable_host_sanitize": false
        }
      ]
    }
  ]
  }

路线“ / facebook / login”正在调用定义如下的方法

func FacebookLoginHandler(w http.ResponseWriter,r *http.Request) {

  //w.Header().Set("Content-Type","text/plain") 
  w.Header().Set("Content-Type","text/html; charset=utf-8")
  w.WriteHeader(http.StatusOK)
  
    facebookOauthConfig = &oauth2.Config{
        ClientID:     "XXXXXXXXXXXXX",ClientSecret: "XXXXXXXXXXXXXXXXXXXXXXXXXX",RedirectURL:  "https://DOMAINE_NAME.com/facebook/callback",Scopes:       []string{"public_profile"},Endpoint:     facebook.Endpoint,}

    url := facebookOauthConfig.AuthCodeURL(oauthStateStrings)
  http.Redirect(w,r,url,http.StatusFound)
}

功能应该将我重定向生成的外部URL“ www.facebook.com /..../?...&...” 让我们的应用程序弹出窗口在通过回调函数进行连接之前。

但是这个URL是我们应用程序外部的,而不是预先定义在服务器Krakend中的事实 响应并显示500错误代码

如何解决问题或在KrakenD配置文件中设置外部URL?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)