Firebase-tools: Can't deploy Hosting with Cloud Function rewrite

Created on 18 May 2017  ยท  6Comments  ยท  Source: firebase/firebase-tools

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"
    }
  }
}

Most helpful comment

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?

All 6 comments

I'm curious -- if you make the "source" slightly longer, e.g. "/vee" does
it work? Might be a spurious server-side validation error.

On Wed, May 17, 2017 at 5:13 PM pejalo notifications@github.com wrote:

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/
Wed May 17 2017 17:01:47 GMT-0700 (PDT)
[debug] <<< HTTP RESPONSE 200
[debug] >>> HTTP REQUEST GET https://admin.firebase.com/v1/database//tokens
Wed May 17 2017 17:01:48 GMT-0700 (PDT)
[debug] <<< HTTP RESPONSE 200
[info]
[info] === Deploying to ''...
[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//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//releases",
"path": "/v1/projects//releases",
"href": "https://deploy.firebase.com/v1/projects//releases"
},
"method": "POST"
}
}
}

โ€”
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/firebase/firebase-tools/issues/336, or mute the
thread
https://github.com/notifications/unsubscribe-auth/AAAD_psaBoYmCy8IdcA6Fg7VehfI0Xnbks5r640rgaJpZM4NelgU
.

@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.

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

@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.

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?

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 :)

Was this page helpful?
0 / 5 - 0 ratings