Sae
Sae

Reputation: 505

get History version from firebase hosting

I have site that deployed on firebase hosting site on the site I wrote Version 3 but instead of that I want to show the deployment / release version like e925c5 that writen on the history version.

can I get history version with Rest API.? or can I define it before deployed.? thank you

Update

I try with reading documentation and working with it, but still stuck with the authentication method,

Simple function is this, but always returned 403 response, already try with getGlobalDefaultAccount.login() and getGlobalDefaultAccount.getAccessToken() and getGlobalDefaultAccount() still not working,

const requireAuth = require('firebase-tools/lib/requireAuth')
const getGlobalDefaultAccount = require('firebase-tools/lib/auth')
const api = require('firebase-tools/lib/api')

const site = 'sarafe-testing'
requireAuth(getGlobalDefaultAccount.getAccessToken(), ['https://www.googleapis.com/auth/cloud-platform']).then(async () => {
  try {
    const response = await api.request('GET', `/v1beta1/sites/${site}/releases`, { auth: true, origin: api.hostingApiOrigin })
    console.log(response)
  } catch(e) {
    console.log(e.message)
  }
})

Full version

For now I just created table that hold version code (manuali update from firebase page) and make API to get the version, but this not a valid solution because is only show the latest version, some other people just open the webpage without refresh / clear cache so that one is still using the old version of webpage with latest version written,

Upvotes: 0

Views: 992

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 599591

Yes, there is a REST API that allows you to manage versions and releases for Firebase Hosting, and it has a method to get a list of versions for the site. I recommend checking out its documentation and reporting back if you get stuck while implementing the code.

Upvotes: 0

Related Questions