cloudflare / cloudflare/workers-sdk
🐛 BUG: Wildcard is used after return of a more specific route
- Dominant language
- TypeScript
- Stars
- 4.5k
- Forks
- 1.5k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 187
Description
### What version of `Wrangler` are you using?
2.6.1
### What operating system are you using?
MacOS
### Describe the Bug
Using `wrangler pages dev .` and having the following file structure:
```
── functions
├── [[path]].js
├── _middleware.js
├── index.js
```
Consider `index.js` doing this:
```javascript
export async function onRequest(context) {
return new Response('Doing something on root index');
}
```
and `[[path]].js` this:
```javascript
export async function onRequest(context) {
return new Response('Doing something instead of 404 :-)');
}
```
Opening the root `http://127.0.0.1:8788/` will return the wildcard match (print: `'Doing something instead of 404 :-)'`).
I would expect to let the more specific route to "return its `new Response()`" but it's completely lost. This behavior should only be if one would call `context.next()` from `index.js`.
Contributor guide
Assessment
This issue has not been assessed yet.