diff --git a/packages/next/shared/lib/head.tsx b/packages/next/shared/lib/head.tsx index 31d86fc503d7c26..81d339e21a9f3c9 100644 --- a/packages/next/shared/lib/head.tsx +++ b/packages/next/shared/lib/head.tsx @@ -162,7 +162,8 @@ function reduceComponents( } } if (process.env.NODE_ENV === 'development') { - if (c.type === 'script') { + // omit JSON-LD structured data snippets from the warning + if (c.type === 'script' && c.props['type'] !== 'application/ld+json') { const srcMessage = c.props['src'] ? ` + +

I can have meta tags

+ +) diff --git a/test/integration/client-navigation/test/index.test.js b/test/integration/client-navigation/test/index.test.js index 06d4bb57f88f67c..42d3906517519b1 100644 --- a/test/integration/client-navigation/test/index.test.js +++ b/test/integration/client-navigation/test/index.test.js @@ -1414,6 +1414,29 @@ describe('Client Navigation', () => { } }) + it('should not warn when application/ld+json scripts are in head', async () => { + let browser + try { + browser = await webdriver(context.appPort, '/head-with-json-ld-snippet') + + await browser.waitForElementByCss('h1') + await waitFor(2000) + const browserLogs = await browser.log('browser') + let found = false + browserLogs.forEach((log) => { + console.log('log.message', log.message) + if (log.message.includes('Use next/script instead')) { + found = true + } + }) + expect(found).toEqual(false) + } finally { + if (browser) { + await browser.close() + } + } + }) + it('should warn when stylesheets are in head', async () => { let browser try {