0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Cloud functionsをつかってリダイレクト処理を実行したら、遷移先で「Your client does not have permission to get URL / from this server.」とでる。

Last updated at Posted at 2021-11-13

問題

cloud functionsをつかってOGP画像を設定したリンクをふむと、リダイレクトするようにして設定したのだが、なぜかリダイレクトページがあらわれず、Googleアカウントの認証を求められたり、「Your client does not have permission to get URL / from this server.」とかかれたページがあらわれたりする。

以下のリンクのように、Google Cloud Consoleで権限を付与しても駄目だった。
https://qiita.com/toshiaki_takase/items/ce65cd5582a80917b52f

解決策

公式ドキュメントによると「Firebase Hosting に接続されている関数は us-central1 に配置する必要があります。」とのこと。
どうやらindex.jsのファイル中のhttp関数でregion('asia-northeast1')を設定しているのがいけないらしい。

index.js
exports.f = functions.regions('asia-northeast1').https.onRequest(async (req, res) => {
    const doc_id = req.path.split('/')[2];

だから、以下のようにregionsを抜いてあげて、デフォルトの「us-central1 」に変更すればよい。

index.js
exports.f = functions.https.onRequest(async (req, res) => {
    const doc_id = req.path.split('/')[2];

無事リダイレクトできるようになった!

参考文献

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?