I’m having some trouble proxying from one Netlify app to another. I won’t use actual application names or domains here but can do so privately.
I have two applications:
- An API. This has a custom domain (e.g. api.robsapi.com) and a bunch of functions.
- A SPA React API, say react-rob-ui.netlify.app. I want to proxy requests to react-rob-ui.netlify.app/api to the API so I don’t have to faff about with CORS (at least for now!)
I’m doing some rewriting of URLs for the API app. Here’s the netlify.toml file:
Rewrite API requests to actual location of serverless functions
[[redirects]]
from = “/v1/*”
to = “/.netlify/functions/:splat”
status = 200
I have a “ping” function that returns “pong”. Calling “https://api.robsapi.com/v1/ping” successfully returns “pong” so I know the API application is working as expected.
For the React app, I’ve got the following:
[[redirects]]
from = “/api/*”
to = “https://api.robsapi.com/v1/:splat”
status = 200
force = true
Browsing to “https://react-rob-ui.netlify.app/api/ping” should be proxied through to the API app and then return “pong”. Instead it returns a 200 with an empty body (i.e. no pong!).
Should this work? What am I doing wrong?
TIA,
Rob