Skip to content

Can't deploy Hosting with Cloud Function rewrite #336

Closed

Description

@pejalo

I can't wait to use Hosting + Functions integration! 😃

firebase.json rewrite rule:

...
"hosting": {
    "public": "dist",
    "rewrites": [
      { "source": "/v", "function": "v" }
    ],
...

CLI:
$ firebase deploy --only hosting

i  deploying hosting
i  hosting: preparing dist directory for upload...
✔  hosting: 36 files uploaded successfully
i  starting release process (may take several minutes)...

Error: HTTP Error: 500, An unknown error occurred. Please contact support.

firebase-debug.log:

[debug] ----------------------------------------------------------------------
[debug] Command:      /usr/local/Cellar/node/7.3.0/bin/node /usr/local/bin/firebase deploy --only hosting
[debug] CLI Version:  3.9.0
[debug] Platform:     darwin
[debug] Node Version: v7.3.0
[debug] Time:         Wed May 17 2017 17:01:47 GMT-0700 (PDT)
[debug] ----------------------------------------------------------------------
[debug] 
[debug] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[debug] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/<project name>
 Wed May 17 2017 17:01:47 GMT-0700 (PDT)
[debug] <<< HTTP RESPONSE 200
[debug] >>> HTTP REQUEST GET https://admin.firebase.com/v1/database/<project name>/tokens  
 Wed May 17 2017 17:01:48 GMT-0700 (PDT)
[debug] <<< HTTP RESPONSE 200
[info] 
[info] === Deploying to '<project name>'...
[info] 
[info] i  deploying hosting
[info] i  hosting: preparing dist directory for upload...
[debug] >>> HTTP REQUEST PUT https://deploy.firebase.com/v1/hosting/...
 Wed May 17 2017 17:01:50 GMT-0700 (PDT)
[debug] <<< HTTP RESPONSE 200
[debug] [hosting] .tgz uploaded successfully, waiting for extraction
[info] ✔  hosting: 36 files uploaded successfully
[info] i  starting release process (may take several minutes)...
[debug] >>> HTTP REQUEST POST https://deploy.firebase.com/v1/projects/<project name>/releases { hosting: 
   { public: 'dist',
     rewrites: [ [Object] ],
     headers: [ [Object] ],
     version: ...,
     prefix: ...,
     manifest: [] } } 
 Wed May 17 2017 17:01:55 GMT-0700 (PDT)
[debug] <<< HTTP RESPONSE 500
[debug] <<< HTTP RESPONSE BODY
[error] 
[error] Error: HTTP Error: 500, An unknown error occurred. Please contact support.
[debug] Error Context: {
  "body": {
    "error": {
      "code": "UNKNOWN_ERROR",
      "message": "An unknown error occurred. Please contact support."
    }
  },
  "response": {
    "statusCode": 500,
    "body": {
      "error": {
        "code": "UNKNOWN_ERROR",
        "message": "An unknown error occurred. Please contact support."
      }
    },
    "headers": {
      "server": "nginx",
      "date": "Thu, 18 May 2017 00:01:57 GMT",
      "content-type": "application/json; charset=utf-8",
      "content-length": "97",
      "connection": "close",
      "access-control-allow-origin": "*",
      "access-control-allow-methods": "GET, PUT, POST, DELETE, OPTIONS",
      "strict-transport-security": "max-age=31556926; includeSubDomains; preload",
      "x-content-type-options": "nosniff"
    },
    "request": {
      "uri": {
        "protocol": "https:",
        "slashes": true,
        "auth": null,
        "host": "deploy.firebase.com",
        "port": 443,
        "hostname": "deploy.firebase.com",
        "hash": null,
        "search": null,
        "query": null,
        "pathname": "/v1/projects/<project name>/releases",
        "path": "/v1/projects/<project name>/releases",
        "href": "https://deploy.firebase.com/v1/projects/<project name>/releases"
      },
      "method": "POST"
    }
  }
}

Activity

  1. mbleigh commented on May 18, 2017

    @mbleigh
    Contributor
  2. pejalo commented on May 18, 2017

    @pejalo
    Author

    @mbleigh Thanks for the quick response! Great idea. Turns out that the source is ok. It was the function name that was too short. This is great because of course the source is user-facing and the function name doesn't matter.

  3. laurenzlong commented on May 22, 2017

    @laurenzlong
    Contributor

    Hey @pejalo so does this solve your problem? Can you close this issue if it does? Thanks!

  4. pejalo commented on May 23, 2017

    @pejalo
    Author

    @laurenzlong Yes thanks, this worked for me. I still think functions names of a single character should be supported. But it's not a big deal, and at least this issue is here for reference.

  5. mihalik commented on May 25, 2017

    @mihalik

    I know this issue is closed but I just ran into this and it caused a bit of frustration for a while. This issue is good for people that search Google but it would be nice if there was a more general fix. Is there a plan to fix the underlying issue, provide a better error message, or at least update the documentation to state that functions need to be longer than a single character?

  6. SamMatthewsIsACommonName commented on Aug 18, 2017

    @SamMatthewsIsACommonName

    For the record I also encountered this issue because of my own user error. I had a module import incorrenctly (e.g const {MY_FUNCTION} = require(....) vs const MY_FUNCTION = require(...) )
    maybe this helps someone else who has the same problem :)

  7. added a commit that references this issue on Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions