Navigating to an API handler route 404's in logs.
Open
Nobody has claimed this yet.
needs-decision
router
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the bug
Navigating to an API only route yields a 404 in the console. If we do a redirect inside the api route to the app, it does not update the URL correctly.
Reproduction
https://stackblitz.com/edit/sveltejs-kit-template-default-ipxflmtx
- Open dev console
- Click the red link
- Witness error in console
- Observe URL bar is not at the correct route (
/moonlight)
Logs
Error: Not found: /out_there
SvelteKitError control.js:45
navigate client.js:1312
_start_router client.js:2175
_start_router client.js:2066
start client.js:314
async* (index):212
promise callback* (index):211
.localservice@runtime.c8c182a3.js:26:94631
error .localservice@runtime.c8c182a3.js:26
handleError app.js:18
handle_error client.js:1642
navigate client.js:1312
_start_router client.js:2175
_start_router client.js:2066
start client.js:314
<anonymous> (index):212
(Async: promise callback)
<anonymous>
### System Info
```Shell
npx envinfo --system --binaries --browsers --npmPackages "{svelte,@sveltejs/*,vite}"
Need to install the following packages:
envinfo@7.14.0
Ok to proceed? (y)
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 18.20.3 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.2.3 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
@sveltejs/adapter-auto: ^3.3.1 => 3.3.1
@sveltejs/kit: ^2.12.1 => 2.12.1
svelte: ^5.14.4 => 5.14.4
vite: ^6.0.3 => 6.0.3
### Severity
blocking all usage of SvelteKit
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked StackBlitz reproduction and follow the failing navigation in the console, especially the client.js navigate/_start_router and control.js locations shown in the log. Trace the API-only route redirect behavior and verify that visiting the route no longer logs a 404 and that the browser URL becomes /moonlight.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, vite
- Domain
- api, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100