Proxy redirect shows blank page


I’m trying to host two different applications on the same domain, by broadly following the proxy redirect method explained here: [Support Guide] Can I deploy multiple repositories in a single site?

These applications are hosted in separate repos and I’m trying to bind the proxy by using the following method in netlify.toml in the main repo.

  from = "/redirect/*"
  to = ""
  status = 200
  force = true

  from = "/*"
  to = "/"
  status = 200

However this redirect is failing and whenever I go to I get a blank page.

Any help would be really appreciated!

Try adding a base tag in the redirect destination site:

The URL should be that of the destination site.

1 Like

Some progress with this!

It seems to redirect now to the target link, but there’s some mismatch in the served file. I’m using React router to do navigation in site 2 and there’s a catch-all route there for 404 pages. Even though I’m doing the redirection to the base url of site 2, it always shows that 404 page.

Going directly to shows the correct page. Any way to debug which path is this redirection taking to?

In both the cases, I can see the same URL getting hit in the network tab: - showing error in the first case while shows correct page in the second.

Oh I see, what the problem is here. This is React Router (RR) messing up. Since RR depends on the location property, it reflects the changes in the address bar. So what is happening here is:

When you go to, Netlify rewrites that URL to Then, React starts its processing and sees that the address bar has path as somepage. It tries to find your component for somepage. It finds none, and uses your 404 component as the fallback.

Instead, you should set the correct component for somepage path also.

1 Like

Thanks a bunch Hrishikesh! Indeed react router was playing havoc with the entire system.

Additionally, instead of changing base tag, I set PUBLIC_URL environment variable, to make it easier to change this on the fly. Now everything is working correctly :slight_smile:

1 Like