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
84a38ffe
Commit
84a38ffe
authored
Jan 14, 2025
by
Jiachi Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: when metadatabase is set we should not warn (#74840)
parent
1c286dd5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
0 deletions
+74
-0
resolve-opengraph.ts
...ages/next/src/lib/metadata/resolvers/resolve-opengraph.ts
+1
-0
metadata-warnings-missing-metadatabase.test.ts
...a-warnings/metadata-warnings-missing-metadatabase.test.ts
+0
-0
metadata-warnings-with-metadatabase.test.ts
...data-warnings/metadata-warnings-with-metadatabase.test.ts
+73
-0
No files found.
packages/next/src/lib/metadata/resolvers/resolve-opengraph.ts
View file @
84a38ffe
...
...
@@ -83,6 +83,7 @@ function resolveAndValidateImage(
// devtools.
const
shouldWarn
=
!
isUsingVercelSystemEnvironmentVariables
&&
!
metadataBase
&&
(
process
.
env
.
NODE_ENV
===
'production'
||
!
isStaticMetadataRouteFile
)
if
(
shouldWarn
)
{
...
...
test/e2e/app-dir/metadata-warnings/
index
.test.ts
→
test/e2e/app-dir/metadata-warnings/
metadata-warnings-missing-metadatabase
.test.ts
View file @
84a38ffe
File moved
test/e2e/app-dir/metadata-warnings/metadata-warnings-with-metadatabase.test.ts
0 → 100644
View file @
84a38ffe
import
{
nextTestSetup
}
from
'e2e-utils'
const
METADATA_BASE_WARN_STRING
=
'metadataBase property in metadata export is not set for resolving social open graph or twitter images,'
describe
(
'app dir - metadata missing metadataBase'
,
()
=>
{
const
{
next
,
isNextDev
,
skipped
}
=
nextTestSetup
({
files
:
__dirname
,
skipDeployment
:
true
,
overrideFiles
:
{
'app/layout.js'
:
`
export default function Layout({ children }) {
return (
<div>
{children}
</div>
)
}
export const metadata = {
metadataBase: new URL('https://example.com'),
}
`
,
},
})
if
(
skipped
)
{
return
}
// If it's start mode, we get the whole logs since they're from build process.
// If it's development mode, we get the logs after request
function
getCliOutput
(
logStartPosition
:
number
)
{
return
isNextDev
?
next
.
cliOutput
.
slice
(
logStartPosition
)
:
next
.
cliOutput
}
it
(
'should not show warning in vercel deployment output in default build output mode'
,
async
()
=>
{
const
logStartPosition
=
next
.
cliOutput
.
length
await
next
.
fetch
(
'/og-image-convention'
)
const
output
=
getCliOutput
(
logStartPosition
)
expect
(
output
).
not
.
toInclude
(
METADATA_BASE_WARN_STRING
)
})
it
(
'should not warn metadataBase is missing and a relative URL is used'
,
async
()
=>
{
const
logStartPosition
=
next
.
cliOutput
.
length
await
next
.
fetch
(
'/relative-url-og'
)
const
output
=
getCliOutput
(
logStartPosition
)
expect
(
output
).
not
.
toInclude
(
METADATA_BASE_WARN_STRING
)
})
it
(
'should warn for unsupported metadata properties'
,
async
()
=>
{
const
logStartPosition
=
next
.
cliOutput
.
length
await
next
.
fetch
(
'/unsupported-metadata'
)
const
output
=
getCliOutput
(
logStartPosition
)
expect
(
output
).
toInclude
(
'Unsupported metadata themeColor is configured in metadata export in /unsupported-metadata. Please move it to viewport'
)
expect
(
output
).
toInclude
(
'Read more: https://nextjs.org/docs/app/api-reference/functions/generate-viewport'
)
})
it
(
'should not warn for viewport properties during manually merging metadata'
,
async
()
=>
{
const
outputLength
=
next
.
cliOutput
.
length
await
next
.
fetch
(
'/merge'
)
// Should not log the unsupported metadata viewport warning in the output
// during merging the metadata, if the value is still nullable.
const
output
=
next
.
cliOutput
.
slice
(
outputLength
)
expect
(
output
).
not
.
toContain
(
'Unsupported metadata viewport'
)
})
})
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