question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't deploy Hosting with Cloud Function rewrite

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
mihalikcommented, May 25, 2017

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?

1reaction
SamMatthewsIsACommonNamecommented, Aug 18, 2017

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 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Manage functions | Cloud Functions for Firebase - Google
Manage functions · On this page · Deploy functions · Delete functions · Modify a function's name, region or trigger. Rename a function;...
Read more >
Firebase base hosting rewrite rules to function - "Cannot GET ...
My function is Express (to make it easier to handle post/get/etc and have route parameters). Turns out, the request was sent to: ...
Read more >
Troubleshooting Cloud Functions - Google Cloud
User with Project Viewer or Cloud Function role cannot deploy a function ... Cloud Functions responds with an HTTP/2 302 redirect which takes...
Read more >
A Simple Trick to Rewrite Your Cloud Functions URL - Medium
Let's see together how to rewrite Firebase Cloud Functions URLs in an Angular web ... Run firebase deploy --only hosting to send changes...
Read more >
Firebase Cloud Functions Deployment
On Google Cloud Platform, go to your project and make sure Cloud Buid API and Cloud Functions are enabled. And the account that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found