GCP Permission Error And How To Fix It

Cloud function permission error

Sun Sep 04 by Mehmet Kose

How to solve the firebase Error: Forbidden Your client does not have permission to get URL?


I was trying to deploy a NextJS app which lives in a cloud function that runs on Firebase/Google servers.

Firebase Hosting Redirect Function

Yes, you can redirect all Hosting requests to a Cloud Function.

Everything was fine until I switch Node16 environment and upgrade the Firebase CLI. Then I started to see these errors.

Firebase permission error


I have Googled a lot, but there was no document that mentions this and why it’s happening. When I checked the function logs I found my first hint there.

Function logs

At first, the flag about V2 got me thinking that my function was working in v1 when this app was fine and dandy. Some configurations must be changed for the V2 Right? Also, something says that I have a problem with the authentication. I can smell like definitely something should be done in Google Cloud. Let’s get into it.

Google Cloud Select Project

Let’s select the project first that Firebase created for us in Google Cloud.

Google Cloud Functions in Menu

Find Google Cloud Functions in the hamburger menu. And select your function that you are planning to use for your NextJS site.

Cloud Function Permissions Tab

Select the Permissions tab and click “Add”.

Cloud Function Permissions Tab

Now, all we have to do is, adding allUsers principal and selecting Cloud Functions Invoker. Save, then we are done here.

After a while, your function will be callable for the Firebase hosting triggers, and we have solved our problem. Still, it’s weird that Firebase is not granting that permission for us. Reach me out if you feel like you have feedbacks on it.

See you next time.

Sour Cream.

Designed and built in Ireland by Mehmet Kose.

Sour Cream LTD © Copyright 2024 . All rights reserved.