shinyatk
shinyatk

Reputation: 1065

How to rewrites to firebase hosting

I have tried to work on this tutorial which is about creating Cloud Run environment and serving a page on Firebase Hosting.

https://firebase.google.com/docs/hosting/cloud-run#python

The Cloud Run part works as it says on the page, but Firebase Hosting part is not working for me. It get 404 error when I access the PROJECT_ID.web.app/ and PROJECT_ID.firebaseapp.com/ I updated the Firebase CLI version to make it the latest version.

"hosting": {
  "public": "public", // I need to add this since I got an error without specify public dir
  "rewrites": [ {
    "source": "**",
    "run": {
      "serviceId": "helloworld",  // "service name" (from when you deployed the container image)
      "region": "us-central1"     // optional (if omitted, default is us-central1)
    }
  } ]
}

Does anyone have the same issue as well? Thanks!

Upvotes: 0

Views: 290

Answers (1)

Andrew
Andrew

Reputation: 855

I am wondering if you have missed a step in the set up stage. There is a helpful guide that includes the steps for implementation you might want to have a look at.

You can also test your container locally with Docker to rule out any obvious issues first. If you need to install Docker you can follow this guide.

To run your container locally you can do:

PORT=8080 && \
docker run -p 9090:${PORT} -e PORT=${PORT} gcr.io/myproject/my-image:latest

Replace myproject/my-image:latest to the project where the container image is stored on Google Cloud Platform

The PORT environment variable specifies the port your application will use to listen for HTTP or HTTPS requests. This is a requirement from the Container Runtime Contract. In this example, we use port 8080.

http://localhost:9090

Upvotes: 0

Related Questions