Firebase Hosting - Wildcard Redirection

I want to use Firebase Hosting to host an angular application, and I need to create a redirect to some old files in a different URL.

According to Firebase documentation you can do basic redirects

"redirects": [ { "source" : "/foo", "destination" : "/bar", "type" : 301 }, { "source" : "/firebase/*", "destination" : "https://www.firebase.com", "type" : 302 } ] 

But I need a lookup redirection

 "redirects": [ { "source" : "/config/*", "destination" : "//oldsiteurl/config/[match-request]", "type" : 302 }] 

So basically I need myapp.firebase.com/config/some.json to myapp.firebase.com/config/some.json redirected to //oldsiteurl/config/some.json . I have a lot of json files, so I don’t want to match file by file.

Do you know if this is possible?

Thanks!

+8
source share
3 answers

For people who get to this page, you can now use wildcards in the URL:

It is sometimes desirable to capture portions of the source redirect URL and reuse them at the destination. You can do this with a prefix : to identify the segment and optional * after the name to indicate that it should capture the rest of the URL

( source )

+8
source

From the Firebase URL Redirect Documentation (highlighted by me):

If a match is found, the HTTP redirect response is set with the "Location" header set to static in the target line, which can be a relative path or an absolute URL.

Thus, it seems that the wild card of the match is not being redirected.

+1
source
 "redirects": [ { "source": "/subdomain/:random*", "destination": "https://subdomain.myapp.com/:random*", "type": 301 } ] 
0
source

All Articles