Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
79bc150e
Unverified
Commit
79bc150e
authored
Oct 07, 2024
by
Jiachi Liu
Committed by
GitHub
Oct 07, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix missing await of params in metadata route (#70900)
parent
5276321a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
9 deletions
+13
-9
image.rs
crates/next-core/src/next_app/metadata/image.rs
+1
-1
route.rs
crates/next-core/src/next_app/metadata/route.rs
+6
-4
next-metadata-route-loader.ts
...t/src/build/webpack/loaders/next-metadata-route-loader.ts
+6
-4
No files found.
crates/next-core/src/next_app/metadata/image.rs
View file @
79bc150e
...
...
@@ -82,7 +82,7 @@ pub async fn dynamic_image_metadata_source(
const imageModule = {{ {exported_fields_excluding_default} }}
export default async function (props) {{
const {{ __metadata_id__: _, ...params }} = props.params
const {{ __metadata_id__: _, ...params }} =
await
props.params
const imageUrl = fillMetadataSegment({pathname_prefix}, params, {page_segment})
const {{ generateImageMetadata }} = imageModule
...
...
crates/next-core/src/next_app/metadata/route.rs
View file @
79bc150e
...
...
@@ -303,7 +303,7 @@ async fn dynamic_site_map_route_source(
}}
export async function GET(_, ctx) {{
const {{ __metadata_id__: id, ...params }} = ctx.params || {{}}
const {{ __metadata_id__: id, ...params }} =
await
ctx.params || {{}}
const hasXmlExtension = id ? id.endsWith('.xml') : false
if (id && !hasXmlExtension) {{
return new NextResponse('Not Found', {{
...
...
@@ -371,12 +371,14 @@ async fn dynamic_image_route_source(path: Vc<FileSystemPath>) -> Result<Vc<Box<d
}}
export async function GET(_, ctx) {{
const {{ __metadata_id__, ...params }} = ctx.params || {{}}
const params = await ctx.params
const {{ __metadata_id__, ...rest }} = params || {{}}
const restParams = params ? rest : undefined
const targetId = __metadata_id__
let id = undefined
if (generateImageMetadata) {{
const imageMetadata = await generateImageMetadata({{ params }})
const imageMetadata = await generateImageMetadata({{ params
: restParams
}})
id = imageMetadata.find((item) => {{
if (process.env.NODE_ENV !== 'production') {{
if (item?.id == null) {{
...
...
@@ -393,7 +395,7 @@ async fn dynamic_image_route_source(path: Vc<FileSystemPath>) -> Result<Vc<Box<d
}}
}}
return handler({{ params:
ctx.params ? params : undefined
, id }})
return handler({{ params:
restParams
, id }})
}}
"
#
,
resource_path
=
StringifyJs
(
&
format!
(
"./{}.{}"
,
stem
,
ext
)),
...
...
packages/next/src/build/webpack/loaders/next-metadata-route-loader.ts
View file @
79bc150e
...
...
@@ -175,12 +175,14 @@ ${errorOnBadHandler(resourcePath)}
${
await
createReExportsCode
(
resourcePath
,
loaderContext
)}
export async function GET(_, ctx) {
const { __metadata_id__, ...params } = ctx.params || {}
const params = await ctx.params
const { __metadata_id__, ...rest } = params || {}
const restParams = params ? rest : undefined
const targetId = __metadata_id__
let id = undefined
if (generateImageMetadata) {
const imageMetadata = await generateImageMetadata({ params })
const imageMetadata = await generateImageMetadata({ params
: restParams
})
id = imageMetadata.find((item) => {
if (process.env.NODE_ENV !== 'production') {
if (item?.id == null) {
...
...
@@ -196,7 +198,7 @@ export async function GET(_, ctx) {
}
}
return handler({ params:
ctx.params ? params : undefined
, id })
return handler({ params:
restParams
, id })
}
`
}
...
...
@@ -243,7 +245,7 @@ ${errorOnBadHandler(resourcePath)}
${
await
createReExportsCode
(
resourcePath
,
loaderContext
)}
export async function GET(_, ctx) {
const { __metadata_id__: id, ...params } = ctx.params || {}
const { __metadata_id__: id, ...params } =
await
ctx.params || {}
const hasXmlExtension = id ? id.endsWith('.xml') : false
if (id && !hasXmlExtension) {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment