Notes

Firebase Hosting

Redirects

1
"hosting": {
2
// Add the "redirects" section within "hosting"
3
"redirects": [ {
4
"source" : "/foo",
5
"destination" : "/bar",
6
"type" : 301
7
}, {
8
"source" : "/firebase/*",
9
"destination" : "https://firebase.google.com",
10
"type" : 302
11
} ]
12
}
Copied!

Rewrites

1
"hosting": {
2
// Add the "rewrites" section within "hosting"
3
"rewrites": [ {
4
"source": "**",
5
"destination": "/index.html"
6
} ]
7
}
Copied!

Headers

1
"hosting": {
2
// Add the "headers" section within "hosting".
3
"headers": [ {
4
"source" : "**/*[email protected](eot|otf|ttf|ttc|woff|font.css)",
5
"headers" : [ {
6
"key" : "Access-Control-Allow-Origin",
7
"value" : "*"
8
} ]
9
}, {
10
"source" : "**/*[email protected](jpg|jpeg|gif|png)",
11
"headers" : [ {
12
"key" : "Cache-Control",
13
"value" : "max-age=7200"
14
} ]
15
}, {
16
// Sets the cache header for 404 pages to cache for 5 minutes
17
"source" : "404.html",
18
"headers" : [ {
19
"key" : "Cache-Control",
20
"value" : "max-age=300"
21
} ]
22
} ]
23
}
Copied!

Connect a Cloud Function

1
{
2
"hosting": {
3
"public": "public",
4
5
// Add the following rewrites section *within* "hosting"
6
"rewrites": [ {
7
"source": "/bigben", "function": "bigben"
8
} ]
9
10
}
11
}
Copied!
Last modified 3yr ago