Technologies:
Tolerim
17 hours ago
What is the build time for Firebase hosting?
"headers": [
{
"source": "**",
"headers": [
{
"key": "Build-Time",
"value": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
}
]
}
]
const fetchData = async () => {
try {
const response = await fetch('https://simple-login-de1a6.web.app/');
const buildTime = response.headers.get('Build-Time');
console.log('Build Time:', buildTime);
// Use the buildTime value in your project as needed
} catch (error) {
console.error('Error:', error);
}
};
fetchData();
}, []);
Answers(1)
Tolerim
17 hours ago
Verified Answer
It looks like you are trying to collect the build time/deploy time of your Firebase Hosting deployment using the "headers" field in your firebase.json file and then retrieve it in your React app using a fetch call to the URL of your deployed site.
The code you have shared seems correct. However, please make sure that you have deployed the updated firebase.json file to Firebase Hosting. Additionally, check whether the URL you are using in your fetch call is correct.
If the issue still persists, you can try the following troubleshooting steps:
- Open your site in the browser.
- Open the developer console and go to the network tab.
- Look for the request sent to your site and make sure that the Build-Time header is present in the response headers.
- If the header is not present, then there is some issue with the firebase.json file or the deployment process.
- If the header is present in the response headers, then check whether your fetch call is set up correctly.