Complete the code to redirect all HTTP requests to HTTPS in Firebase hosting configuration.
{
"hosting": {
"redirects": [
{
"source": "/**",
"destination": "https://[1]/$1",
"type": 301
}
]
}
}The destination must be your Firebase app domain, such as myapp.web.app, to redirect all requests to HTTPS.
Complete the rewrite rule to serve the index.html file for all URLs in a single-page app.
{
"hosting": {
"rewrites": [
{
"source": "/**",
"destination": "/[1]"
}
]
}
}For single-page apps, all URLs should rewrite to index.html so the app can handle routing.
Fix the error in the redirect rule to properly redirect /old-path to /new-path with a 302 status.
{
"hosting": {
"redirects": [
{
"source": "/old-path",
"destination": "/[1]",
"type": 302
}
]
}
}The destination should be the new path /new-path to redirect correctly.
Fill both blanks to rewrite API requests starting with /api to the cloud function named 'apiHandler'.
{
"hosting": {
"rewrites": [
{
"source": "/[1]/**",
"function": "[2]"
}
]
}
}The source should match the API path prefix api, and the function name is apiHandler to handle those requests.
Fill all three blanks to create a redirect from /blog to /news with a permanent 301 status and a trailing slash added.
{
"hosting": {
"redirects": [
{
"source": "/[1]",
"destination": "/[2]/",
"type": [3]
}
]
}
}The source is blog, destination is news/ with a trailing slash, and type 301 means permanent redirect.