Next.js: Viewport meta tag not being deduplicated

Created on 3 Oct 2019  路  1Comment  路  Source: vercel/next.js

Bug report

Describe the bug

Default viewport tag is being appended to and not replaced whenever you use define your own custom viewport tag.

To Reproduce

Define a simple _app.tsx that attempts to set a custom viewport meta tag.

import App from 'next/app'
import Head from 'next/head'

class MyApp extends App {
  render() {
    const { Component, pageProps } = this.props

    return (
      <>
        <Head>
          <title>Some Title</title>
          <meta name="viewport" content="this-is-from-app.tsx" key="viewport" />
        </Head>
        <Component {...pageProps} />
      </>
    )
  }
}

export default MyApp

Expected behavior

I expected the default viewport tag to be deduplicated and replaced.

Screenshots

image

System information

  • OS: macOS
  • Browser (if applies): Chrome
  • Version of Next.js: 9.0.7

Additional context

After doing some searching, it looks to me like the initial tag is coming from https://github.com/zeit/next.js/blob/2ba352da39ee00b6595aecdc9ffb2f103e803a85/packages/next/next-server/lib/head.tsx#L11-L23 and is not properly being deduplicated. It doesn't seem to matter if you define the same key.

good first issue needs investigation

Most helpful comment

Would like to work on this! Will investigate and send a PR.

>All comments

Would like to work on this! Will investigate and send a PR.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

formula349 picture formula349  路  3Comments

pie6k picture pie6k  路  3Comments

renatorib picture renatorib  路  3Comments

havefive picture havefive  路  3Comments

ghost picture ghost  路  3Comments