Switching to a different apiProxyPath no longer works

Hey folks!

Something I used to do (switching the apiProxyPath in redwood.toml) is no longer working. I’m not sure when it broke, but it worked a week or two ago.

My use case is that I want to be able to run my local web client, but connect to a remote API server. This is either because I’m testing or because there’s better data in a staging environment. The code change below used to work.

  port = 8910
  #apiProxyPath = "/.netlify/functions"
  apiProxyPath = "https://foo-bar-staging.herokuapp.com"
  port = 8911
  open = false

Now when I do this, any URL I request other than the root (i.e. localhost:9810/users) bypasses the web tier, goes straight to the API tier (localhost:8911) and resolves as a 404, since there is no /users function defined on the backend.

Any idea about what changed?

1 Like

Oh wow! I had no idea that this was possible - I’ll look into this for you.

1 Like

Thanks @peterp!

It definitely used to be possible, because I ran a local instance of the Redwood Blog Example App against a remote API server powered by Nexus as a proof of concept for using Nexus with Redwood. Worked quite nicely at one point.

1 Like

@peterp another data point.

I’ve been digging around the redwood source code trying to sort out this issue and I tried something weird. I set apiProxyPath to something really silly:

apiProxyPath = "/foo/bar/"

I then restarted my server and, to my shock, everything worked fine! Which is definitely confusing, but possible a hint at what’s going on?

I hope this helps, I’m currently totally blocked by this. I’ll keep digging!

FYI, Peter opened an Issue here:

1 Like

Ah! I think webpack requires a restart if redwood.toml is changed! We can fix this - I’ll update the issue.

Sorry, I didn’t mean to imply my problem was gone or that the issue was fixed. I meant that I was surprised that I could set apiProxyPath to a nonsense value like "/foo/bar" and have Redwood successfully proxy API requests to localhost:8911.

However, I still can’t set apiProxyPath to a fully qualified URL. It seems like this was once possible in RedwoodJS 0.4.0 and it’s something that Create React App provides out of the box.

1 Like

Whoops! Ok, good to know :slight_smile: