<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/serving-dynamic-content-with-cloud-functions-on-firebase-hosting-vyvmgysxx" -->

---
title: Serving dynamic content with Cloud Functions on Firebase...
description: Firebase Hosting can now connect to Cloud Functions via a rewrite rule in firebase.json, enabling dynamic content behind Firebase's global CDN. This unlocks...
canonical: https://daily.dev/posts/serving-dynamic-content-with-cloud-functions-on-firebase-hosting-vyvmgysxx
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Serving dynamic content with Cloud Functions on Firebase Hosting | daily.dev
og:description: Firebase Hosting can now connect to Cloud Functions via a rewrite rule in firebase.json, enabling dynamic content behind Firebase's global CDN. This unlocks...
og:url: https://daily.dev/posts/serving-dynamic-content-with-cloud-functions-on-firebase-hosting-vyvmgysxx
og:image: https://api.daily.dev/og/posts/VYVMGYSxx.png
og:image:alt: Serving dynamic content with Cloud Functions on Firebase Hosting
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Serving dynamic content with Cloud Functions on Firebase Hosting

**[Firebase](https://daily.dev/sources/firebase-blog)** · 2 min read · 0 upvotes · 0 comments

## Summary

Firebase Hosting can now connect to Cloud Functions via a rewrite rule in firebase.json, enabling dynamic content behind Firebase's global CDN. This unlocks server-side rendering with libraries like Express, custom API endpoints on your own domain (with optional Firebase Auth protection), and dynamically generated content compatible with AMP and Twitter Cards. Cloud Functions can also now run on SSL-secured custom domains with caching to reduce unnecessary executions.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://firebase.blog/posts/2017/06/serving-dynamic-content-with-cloud>

## Questions this post answers

### How do I serve dynamic content from a Cloud Function through Firebase Hosting?

Add a rewrite rule to the firebase.json hosting configuration mapping a source path pattern to a function name, for example routing '/function/**' to 'myFunction'. Once configured, matching requests are proxied to the Cloud Function while still benefiting from Firebase Hosting's global CDN cache, enabling server-side rendering with libraries like Express.

_daily.dev surfaces hands-on Firebase and serverless hosting guides for developers wiring up dynamic routes._

### Can I use Firebase Auth to protect custom API endpoints served through Firebase Hosting?

Yes, custom API endpoints created with Cloud Functions and exposed via Firebase Hosting rewrites can be authorized using Firebase Auth with a few extra lines of code, as shown in the authorized-https-endpoint sample. This also avoids cross-origin request overhead since the API runs on the same domain as the hosted app.

_Developers securing custom APIs can track Firebase Auth patterns and updates on daily.dev._

## Similar posts on daily.dev

- [How to Use Dart Cloud Functions and the Firebase Admin SDK: A Handbook for Developers](https://daily.dev/posts/how-to-use-dart-cloud-functions-and-the-firebase-admin-sdk-a-handbook-for-developers-ailkvowjb) · freeCodeCamp · 2 upvotes · 0 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#serverless](https://daily.dev/tags/serverless), [#firebase](https://daily.dev/tags/firebase), [#gcp-cloud-functions](https://daily.dev/tags/gcp-cloud-functions)

[View this post on daily.dev](https://daily.dev/posts/serving-dynamic-content-with-cloud-functions-on-firebase-hosting-vyvmgysxx)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Serving dynamic content with Cloud Functions on Firebase Hosting","url":"https://daily.dev/posts/serving-dynamic-content-with-cloud-functions-on-firebase-hosting-vyvmgysxx","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/serving-dynamic-content-with-cloud-functions-on-firebase-hosting-vyvmgysxx"},"datePublished":"2026-08-23T12:18:39.341Z","dateModified":"2026-08-24T07:00:00.795Z","description":"Firebase Hosting can now connect to Cloud Functions via a rewrite rule in firebase.json, enabling dynamic content behind Firebase's global CDN. This unlocks...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7ed721de96163685d26ab7e314be3ebc?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7ed721de96163685d26ab7e314be3ebc?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Firebase","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Firebase","logo":"https://media.daily.dev/image/upload/s--i395oqZH--/f_auto,q_auto/v1787487448/logos/firebase-blog?_a=BAMAMicg0","url":"https://daily.dev/sources/firebase-blog"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/serving-dynamic-content-with-cloud-functions-on-firebase-hosting-vyvmgysxx","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"webdev,serverless,firebase,gcp-cloud-functions","timeRequired":"PT2M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Firebase","item":"https://daily.dev/sources/firebase-blog"},{"@type":"ListItem","position":3,"name":"Serving dynamic content with Cloud Functions on Firebase Hosting"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/serving-dynamic-content-with-cloud-functions-on-firebase-hosting-vyvmgysxx#faq","mainEntity":[{"@type":"Question","name":"How do I serve dynamic content from a Cloud Function through Firebase Hosting?","acceptedAnswer":{"@type":"Answer","text":"Add a rewrite rule to the firebase.json hosting configuration mapping a source path pattern to a function name, for example routing '/function/**' to 'myFunction'. Once configured, matching requests are proxied to the Cloud Function while still benefiting from Firebase Hosting's global CDN cache, enabling server-side rendering with libraries like Express. daily.dev surfaces hands-on Firebase and serverless hosting guides for developers wiring up dynamic routes."}},{"@type":"Question","name":"Can I use Firebase Auth to protect custom API endpoints served through Firebase Hosting?","acceptedAnswer":{"@type":"Answer","text":"Yes, custom API endpoints created with Cloud Functions and exposed via Firebase Hosting rewrites can be authorized using Firebase Auth with a few extra lines of code, as shown in the authorized-https-endpoint sample. This also avoids cross-origin request overhead since the API runs on the same domain as the hosted app. Developers securing custom APIs can track Firebase Auth patterns and updates on daily.dev."}}]}
```

