-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
URLSearchParams - getAll() is not returning proper array in edge runtime. #340
Comments
I ran the code now with if you want to check the bug in production: |
Hello, I'm not seeing how Using Node.js repl: > new URL('https://og.codante.io/api/test/first-segment/second-segment').searchParams.getAll('name')
[] They should be query parameters rather than part of the URL, like in this way: new URL('https://og.codante.io/api/test?name=first-segment&name=second-segment').searchParams.getAll('name')
[ 'first-segment', 'second-segment' ] Please correct me if I'm wrong; happy to re-open the issue if needed. |
Hello @Kikobeats, When i have a catch all route, NextJS injects the segments into Sorry if i wasn't clear, but I am sure that this problem is a bug. Local and edge production environment are getting different results with the exact same code. Edge Runtime (bug): https://og.codante.io/api/edge/first/second - Below is the code that is running in production (link here): export const config = {
runtime: 'edge',
};
export default function handler(req) {
const { searchParams } = new URL(req.url);
const allSegments = searchParams.getAll('name');
return new Response(JSON.stringify({ allSegments }), { status: 200 });
} |
Hello @Kikobeats any chance reopening this? When we run this in node: But when we run the same code in edge-runtime (production nextjs deployment @vercel ), the result is not the expected. Please check this live: |
Hey @robertotcestari, I reopened the issue; definitively we have to take a look! |
Bug Report
Current behavior
Using NextJS 13.4, using API routes (Pages Folder) in the following folder structure:
pages/api/[...name].jsx
When i try to use the method
getAll()
on the routeBASE_URL/api/first-segment/second-segment
:the expected return from
getAll()
was to be an array like:This works correct in
localhost
and in chrome js console.However, when pushing to production (edge runtime), it gives the following code:
... which is different from the Web API implementation.
Expected behavior/code
From the example above,
searchParams.getAll(param)
was expected to return an array with two items. It returned one array with only one item.The text was updated successfully, but these errors were encountered: