mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
The previous RegExp for data routes when i18n was enabled yielded a pattern like: ``` ^\/_next\/data\/development\/(?<nextLocale>.+?)\/about.json$ ^\/_next\/data\/development\/(?<nextLocale>.+?)\/blog/about.json$ ``` But the capture group for the `nextLocale` did so greedily, where the following: ``` /_next/data/development/en-US/blog/about.json ``` Would actually match both routes. This changes it to prevent the locale from including a `/` via `[^/]`, resulting in the new expressions: ``` ^\/_next\/data\/development\/(?<nextLocale>[^/]+?)\/about.json$ ^\/_next\/data\/development\/(?<nextLocale>[^/]+?)\/blog/about.json$ ```
13 lines
317 B
TypeScript
13 lines
317 B
TypeScript
import React from 'react'
|
|
|
|
export function Page({ page }) {
|
|
return <p data-page={page}>{page}</p>
|
|
}
|
|
|
|
export function createGetServerSideProps(page: string) {
|
|
return async function getServerSideProps(ctx) {
|
|
const output = ctx.req.headers['x-invoke-output'] ?? null
|
|
return { props: { page, output } }
|
|
}
|
|
}
|