This diff adds a new --path param that hosts dagit and the /graphql endpoint at a subpath. No requests assume the root path, and hitting the root redirects to the prefixed path (just in case the user has not mounted something else at the root of the domain). The path you choose is injected into the the React app via a meta tag in the HTML, and is used to do two things:
- We give React Router the path prefix. This makes most of the app "just work" which is actually fairly surprising - <Link to="/bla"> goes to "/path/bla" and <Route path="/bla" /> handles "/path/bla".
- We store the path prefix and manually append it when we have to build URLs from scratch, eg: for opening new windows / tabs. To make this less of a pain point, I consolidated code that handles the launch/relaunch responses (it was nearly identical) so there is only one place in the app we manually assemble a run URL.
Dev workflow: Right now there's not a great way to test this when you're running the React app via make. To test this, you need to build the React app (yarn build-for-python) and then serve it with dagit. I would like to change this and use a subpath all the time during development because it'd enforce good hygiene / prevent us from breaking support for paths in the future by accident, but I haven't found a good way to do it yet.