Skip to content

fix: include admin_basepath in absolute navigation paths#368

Open
cameronapak wants to merge 1 commit intorelease/0.21from
fix-sidebar-route-users
Open

fix: include admin_basepath in absolute navigation paths#368
cameronapak wants to merge 1 commit intorelease/0.21from
fix-sidebar-route-users

Conversation

@cameronapak
Copy link
Copy Markdown
Collaborator

@cameronapak cameronapak commented Mar 17, 2026

Continuation of #218

Problem

`useNavigate` with `{ absolute: true }` only prepended `basepath` but not `admin_basepath` when constructing URLs. This caused links like the Data/Schema segmented control to navigate to `/data` instead of `/admin/data` when `admin_basepath` is set.

Replicate

Visit /admin/data/schema and then click on Data on the segmented button. It would take the user to /data instead of /{admin_basepath}/data

CleanShot 2026-03-17 at 16 23 22@2x

Changes

  • src/ui/lib/routes.ts: Include `admin_basepath` in the absolute URL construction in `useNavigate`.
  • src/ui/Admin.tsx: Add `admin_basepath` to `BkndAdminConfig` type so TypeScript recognizes it on the options object.

Fixes navigate(..., { absolute: true }) only prepending basepath but
missing admin_basepath, causing links like /data instead of /admin/data.

Adds admin_basepath to BkndAdminConfig type.

Amp-Thread-ID: https://ampcode.com/threads/T-019cfd9f-89ca-703c-a86c-99eef60e3fe8
Co-authored-by: Amp <amp@ampcode.com>
@cameronapak cameronapak changed the base branch from main to release/0.21 March 17, 2026 21:24
@cameronapak cameronapak mentioned this pull request Mar 17, 2026
@cameronapak cameronapak added Needs Review This is a PR that needs review from the bknd team Needs Feedback from Dennis Add this tag to any PR that needs Dennis's feedback or final sign off labels Mar 17, 2026
@cameronapak cameronapak added this to the v0.21.0 milestone Mar 17, 2026
@jonaspm
Copy link
Copy Markdown
Contributor

jonaspm commented Mar 24, 2026

I noticed there is an error thrown when building bknd because of this.

@dswbx
Copy link
Copy Markdown
Contributor

dswbx commented Mar 28, 2026

@jonaspm just tested the build and it runs fine, which error are you seeing?

@cameronapak is this fix relevant to the dev command (or when using as static files) or when used inside a framework?

@dswbx
Copy link
Copy Markdown
Contributor

dswbx commented Mar 28, 2026

@cameronapak what problem are you solving exactly? I couldn't reproduce the issue. I've tried running it with bun run dev (which is also how it works when used statically) and also within the astro example, both with your changed added and reverted – without seeing a difference 🤔

@jonaspm
Copy link
Copy Markdown
Contributor

jonaspm commented Mar 28, 2026

@dswbx my bad, not an error but a type warning... huh I am unable to reproduce it on the release/0.21 branch, guess it is good signal.

@dswbx
Copy link
Copy Markdown
Contributor

dswbx commented Mar 28, 2026

It is a good sign indeed 😃

@cameronapak
Copy link
Copy Markdown
Collaborator Author

@cameronapak what problem are you solving exactly? I couldn't reproduce the issue. I've tried running it with bun run dev (which is also how it works when used statically) and also within the astro example, both with your changed added and reverted – without seeing a difference 🤔

I can see you have some confusion and I hope to help clear things up. Watch this video of me replicating this big in v0.21.0-rc.1 of bknd in Freedom Stack v3

CleanShot.2026-03-28.at.05.50.00.mp4

I'm also unfortunately running into this bug again with Admin UI routes not retaining the admin basepath:

CleanShot.2026-03-28.at.05.52.31.mp4

@jonaspm
Copy link
Copy Markdown
Contributor

jonaspm commented Mar 28, 2026

@dswbx wild type error appeared:
image

Property 'admin_basepath' does not exist on type '{ basepath: string; logo_return_path: string; theme?: "system" | "dark" | "light" | undefined; entities?: BkndAdminEntitiesOptions | undefined; appShell?: BkndAdminAppShellOptions | undefined; }'.

@dswbx
Copy link
Copy Markdown
Contributor

dswbx commented Mar 28, 2026

Yeah noticed that one too, fixed that in the upstream release/0.21 branch

@cameronapak
Copy link
Copy Markdown
Collaborator Author

Yeah noticed that one too, fixed that in the upstream release/0.21 branch

Does that mean this PR can/should be closed? If so, please do close it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Feedback from Dennis Add this tag to any PR that needs Dennis's feedback or final sign off Needs Review This is a PR that needs review from the bknd team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants