簡體   English   中英

firebase 路由上 golang 中的 google cloud function gen2 的身份驗證問題

[英]Authentication problem with google cloud function gen2 in golang on firebase routing

我正在測試 go gen2 google cloud functions,function 的代碼部署正常,工作正常,一切正常。 function名為readrequest,對所有人開放。 你可以到達它https://readrequest-v7disnxdea-uc.a.run.app

我還毫無問題地將映射添加到專用子域。

現在我正在嘗試在一個 web firebase 應用程序中進行路由。 為此,我添加了一條到 firebase.json 的路線

firebase.json 中的規則如下所示:

{
  "hosting": {
    "public": "public",
    "rewrites": [

      {
        "source": "/l",
        "function": "l3"
      },
      {
        "source": "/gotest",
        "function": "readrequest"
      },
      {
        "source": "/gotest/**",
        "function": "readrequest"
      },
      {
        "source": "/rc1",
        "function": "rc1"
      },
      {
        "source": "/rc2",
        "function": "rc2"
      },
      {
        "source": "/rc2/**",
        "function": "rc2"
      },
      {
        "source": "/rc1/**",
        "function": "rc1"
      }
    ],
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  }
}

我可以訪問該功能,總是要求進行身份驗證,但即使我接受身份驗證,它也不起作用。 我在 us-central1 中創建了 function 以避免出現問題。

錯誤是:

Error: Forbidden
Your client does not have permission to get URL /readrequest/gotest/asdf from this server.

如果我拼錯了 function 名稱,我會得到同樣的錯誤,所以就像路由器沒有找到 function,但為什么不呢。

因為 Cloud Functions gen2 在 Cloud Run 之上運行(url、權限、日志和許多其他東西都是相同的),所以到達 Cloud Functions gen2 的方式不是通常的 Cloud Functions gen1 方式,而是 Cloud Run 方式!

購買方式,替換 function (gen1) reference "function": "readrequest" , functions (gen2, ie Cloud Run) reference "run": { "serviceId": "readrequest", "region": "us-central1" }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM