'Make proxy configuration works with firebase hosting

I have an angular app with some proxy configuration.

proxy.conf.js

  {
    "/my-api": {
      "target": "http://app.myapp.fr",
      "secure": false,
      "changeOrigin": true,
      "pathRewrite": {"^/my-api" : "api"}
    }
  }

I host my app with firebase hosting. According to firebase doc, I configured firebase.json this way:

"rewrites": [
    {
      "source": "/my-api/:request*",
      "destination": "http://app.myapp.fr/api/:request",
      "type": 301
    }
  ]

but I ended up with a 404, it seems like the redirect is not working...



Solution 1:[1]

According to the docs, that's not possible. You can only proxy to specific functions.

You'll need to put an express server inside this one with a proxy: https://www.npmjs.com/package/http-proxy-middleware

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Doho123