starlight_help: Forward to help_center_port in case of dev server.

Fixes
https://chat.zulip.org/#narrow/channel/19-documentation/topic/new.20help.20center.3A.20run-dev.20options/near/2238128.

When running the dev server, astro/starlight makes a lot of requests on
the base URL, which are not scoped to /starlight_help. We need to host
the dev server on it's own port for it to work well. This commit fixes
that.
This commit is contained in:
Shubham Padia
2025-08-13 08:51:10 +00:00
committed by Tim Abbott
parent 8bdb0b119f
commit 3f6520e82a
2 changed files with 13 additions and 3 deletions

View File

@@ -173,6 +173,14 @@
want to visualize the changes quickly in the beta help center documentation. You will need the want to visualize the changes quickly in the beta help center documentation. You will need the
converted MDX files to be already generated through converted MDX files to be already generated through
<code>./tools/convert-help-center-docs-to-mdx</code> before you run the dev server with this flag. <code>./tools/convert-help-center-docs-to-mdx</code> before you run the dev server with this flag.
<ul>
<li>
The dev server makes a bunch of request to base Zulip URL instead of scoping it to the astro/starlight
base url. For this reason, we run the dev server on it's own port and redirect help center requests to
the appropriate port (9995 by default).
</li>
</ul>
</li> </li>
</ul> </ul>
</div> </div>

View File

@@ -345,11 +345,13 @@ The instructions for the build step can be found in the `./devtools`
page. `/starlight_help` urls will give you an error until you complete the page. `/starlight_help` urls will give you an error until you complete the
build step and rerun `run-dev`.""") build step and rerun `run-dev`.""")
elif enable_help_center_dev_server: elif enable_help_center_dev_server:
async def redirect_help(request: web.Request) -> web.HTTPFound:
return web.HTTPFound(request.url.with_port(help_center_port))
app.add_routes( app.add_routes(
[ [
web.route( web.route(hdrs.METH_ANY, r"/{path:(starlight_help).*}", redirect_help),
hdrs.METH_ANY, r"/{path:(starlight_help).*}", partial(forward, help_center_port)
),
] ]
) )
app.add_routes( app.add_routes(