Open acidjazz opened 2 months ago
confirmed for DELETE as well
Thanks, please ping me when made reproduction but i would guess issue is from old radix3 behavior. If you can try against h3-nightly (v2) that would be amazing.
https://stackblitz.com/edit/github-zdmzwb?file=server%2Fapi%2F%5B...slug%5D.ts
I found that this was because I did not prepend the route with a /
import { createRouter, defineEventHandler, useBase } from 'h3';
const router = createRouter();
router.get(
'/**',
defineEventHandler((event) => 'not found')
);
router.put(
'user/:user/pen/:id',
defineEventHandler((event) => {
return {
parms: event.context.params,
};
})
);
export default useBase('/api/', router.handler);
returns :
data : {
"parms": {
"_": "user/1/pen/2"
}
}
while adding the slash:
import { createRouter, defineEventHandler, useBase } from 'h3';
const router = createRouter();
router.get(
'/**',
defineEventHandler((event) => 'not found')
);
router.put(
'/user/:user/pen/:id',
defineEventHandler((event) => {
return {
parms: event.context.params,
};
})
);
export default useBase('/api/', router.handler);
works fine:
data : {
"parms": {
"user": "1",
"id": "2"
}
}
i'm not sure if this is expected behavior, if it is im happy to close this
Environment
in
/server/api/[...slug].ts
i havethen my handler function has the following.
which ends up showing:
Reproduction
ill whip up a stackblitz asap and report back
Describe the bug
i should see context.params.id and context.params.user populated
Additional context
No response
Logs
No response