Skip to content

Commit

Permalink
Fix query normalize on edge deploy (#48045)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Apr 6, 2023
1 parent 2a68ecf commit fc29a13
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/next/src/server/web-server.ts
Expand Up @@ -23,6 +23,7 @@ import { isDynamicRoute } from '../shared/lib/router/utils'
import { interpolateDynamicPath, normalizeVercelUrl } from './server-utils'
import { getNamedRouteRegex } from '../shared/lib/router/utils/route-regex'
import { IncrementalCache } from './lib/incremental-cache'
import { NEXT_QUERY_PARAM_PREFIX } from '../lib/constants'
interface WebServerOptions extends Options {
webServerConfig: {
page: string
Expand Down Expand Up @@ -104,6 +105,18 @@ export default class NextWebServer extends BaseServer<WebServerOptions> {
res: BaseNextResponse,
parsedUrl: UrlWithParsedQuery
): Promise<void> {
for (const key of Object.keys(parsedUrl.query)) {
const value = parsedUrl.query[key]

if (
key !== NEXT_QUERY_PARAM_PREFIX &&
key.startsWith(NEXT_QUERY_PARAM_PREFIX)
) {
const normalizedKey = key.substring(NEXT_QUERY_PARAM_PREFIX.length)
parsedUrl.query[normalizedKey] = value
delete parsedUrl.query[key]
}
}
super.run(req, res, parsedUrl)
}
protected async hasPage(page: string) {
Expand Down

0 comments on commit fc29a13

Please sign in to comment.