How to configure react app with a router and docusaurus app on the /docs path

Hello,

I have two netlify apps building two different static apps,

One is a create-react-app that uses react-router and the other is a docusaurus static app.

So in a nutshell:

myapp.com/login # React App
myapp.com/profile # React App

myapp.com/docs # Redirect to docusaurus netlify app
myapp.com/docs/getting-started # docusaurus app with its own router

The react app netlify.toml is as follows

[[redirects]]
  from = "/docs"
  to = "https://docusaurus-website.netlify.com"
  status = 200

# Redirect to / so react-router works.
[[redirects]]
  from = "/*"
  to = "/"
  status = 200

I want to host my docusaurus site on mysite.com/docs however when i set the baseUrl to /docs my site is rendered but the assets do not load and the docusaurus router does not work.

Am I doing this the best way?

Hey @karltaylor,
Yup, this looks like the right pattern :slight_smile: It’s similar to this one:

For the baseUrl for your docs site config, I would start with / as described in the Docusaurus docs.

As for your redirect rules, your first one will likely need a * and :splat:

  from = "/docs/*"
  to = "https://docusaurus-website.netlify.com/:splat"
  status = 200!

And the second one might need to be to = "/index.html".

Want to give this all a try and let us know if it works for you?