Adam Thompson
Adam Thompson

Reputation: 457

Firebase Proxy (reverse proxy)

I recently discovered Netlify’s proxying feature, and it’s exactly the functionality I’m looking for. However, our team is heavily invested in Firebase, and adopting another provider is something higher-ups may not want to do.

My Netlify _redirects file looks like this

/ / 200
/* https://my-app.firebaseapp.com/:splat 200

So, is it possible to do a similar proxy with Firebase? I want the base path / to route to index.html, but all other paths /* to proxy to another server my-app.firebaseapp.com.

I've tried using Redirects and Rewrites, but the former requires a 3xx code and changes the url, and the later requires local files. I have a hunch the solution is to use Functions, but I'm not exactly sure.

Upvotes: 1

Views: 1779

Answers (1)

Michael Bleigh
Michael Bleigh

Reputation: 26333

That's correct -- to proxy traffic to arbitrary external URLs you will need to use the Firebase Hosting integration with Cloud Functions or Cloud Run. You can use e.g. node-http-proxy to forward requests, or manually construct the HTTP fetch and respond with the results.

Upvotes: 1

Related Questions