skip to Main Content

Based on the firebase hosting documentation, I’m trying to update the header configuration (without having to redeploy everything, which is important in my case).

https://firebase.google.com/docs/reference/hosting/rest/v1beta1/sites.versions/patch

However, I can’t do it, I always get an error.

Here’s the URL
https://firebasehosting.googleapis.com/v1beta1/sites/SITE_NAME/versions/VERSION_ID?updateMask=config

Here’s the body of my request:

{
    "config": {
        "headers": [
            {
              "headers": {
                "Content-Security-Policy": "frame-src https://...
              },
              "glob": "**/*"
            }
          ]
    }
}

The response:

{
    "error": {
        "code": 400,
        "message": "Request contains an invalid argument.",
        "status": "INVALID_ARGUMENT"
    }
}

Note that when I try to modify the labels (for example), it works.

{
    "labels": {
        "foo":"bar"
    }
}

Does anyone have a solution?

2

Answers


  1. Chosen as BEST ANSWER

    Thanks for your reply,

    I had already tried this solution, but unfortunately it didn't work.

    Here is the response:

    {
    "error": {
        "code": 400,
        "message": "Invalid JSON payload received. Unknown name "Content-Security-Policy" at 'version.config.headers[0]': Cannot find field.",
        "status": "INVALID_ARGUMENT",
        "details": [
            {
                "@type": "type.googleapis.com/google.rpc.BadRequest",
                "fieldViolations": [
                    {
                        "field": "version.config.headers[0]",
                        "description": "Invalid JSON payload received. Unknown name "Content-Security-Policy" at 'version.config.headers[0]': Cannot find field."
                    }
                ]
            }
        ]
    }
    

    }


  2. can you try

    {
        "config": {
            "headers": [
                {
                    "Content-Security-Policy": "frame-src https://...",
                    "glob": "**/*"
                }
            ]
        }
    }
    

    insted of

    {
        "config": {
            "headers": [
                {
                  "headers": {
                    "Content-Security-Policy": "frame-src https://...
                  },
                  "glob": "**/*"
                }
              ]
        }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search