Open setterst opened 1 month ago
The same problems exists for Pages. I created a fix for pages in #1764 , should be easy to extend this to api routes.
However, I'm not sure this is an issue that should be fixed in code. You should be validating user input anyway, so i settled on an approach like this:
eg. using zod
export default withPageAuthRequired(async function OrderPage({
searchParams: unsafeSearchParams,
params: unsafeParams,
}) {
const { timerange } = z
.object({ timerange: timerangeSchema })
.parse(unsafeParams);
const sParams = orderSearchParamsSchema.parse(unsafeSearchParams);
[...]
}
The problem remains that the situation right now is far from ideal: People using Typescript will follow the docs and encounter errors.
Checklist
Description
Following the NextJS documentation for app router Dynamic Route Segments, the Typescript compiler will produce build errors when executing
next build
.Switching the route file to compile in JavaScript, route slug is populated as expected.
Reproduction
file: /app/api/test/[slug]/route.ts route: /api/test/aaaaa
expect TypeScript to compile and the slug parameter to be populated with 'aaaaa'
Additional context
No response
nextjs-auth0 version
3.5.0
Next.js version
14.2.5
Node.js version
22.4.1