aws-amplify / amplify-hosting

AWS Amplify Hosting provides a Git-based workflow for deploying and hosting fullstack serverless web applications.
https://aws.amazon.com/amplify/hosting/
Apache License 2.0
459 stars 116 forks source link

when use dangerouslySetInnerHTML render twice in Nextjs on Aws amplify #3709

Open rocerchen opened 1 year ago

rocerchen commented 1 year ago

Before opening, please confirm:

App Id

dspteuym76kn4

AWS Region

us-east-2

Amplify Hosting feature

SSR

Frontend framework

Next.js

Next.js version

^13.4.19

Next.js router

Pages Router

Describe the bug

i use the code in Head tag <script type="application/ld+json" nonce="xx" dangerouslySetInnerHTML={{ __html: JSON.stringify(data.ld_json) }} /> when firtst visit site, its render twice in head (chrome devtools). (chrome view-source is render once, that is correct) And click another page , its render new page dangerouslySetInnerHTML data once and render prev page dangerouslySetInnerHTML data again.

build on localhost is work fine.

Expected behavior

dangerouslySetInnerHTML data render once, and not to render prev page dangerouslySetInnerHTML data when visit another page

Reproduction steps

  1. visit https://coindada.com/exchanges/coinw/
  2. open chrome devtools
  3. search "application/ld+json", You will see two results. But in fact, only one will be taken.(it has only one when check on chrome view-source)
  4. click to visit another page.
  5. application/ld+json of prev page will remain on the page, so The page has its own application/ld+json and the previous page's application/ld+json (check on chrome devtools). its not correct.

Build Settings

No response

Log output

``` # Put your logs below this line ```

Additional information

No response

rocerchen commented 1 year ago

I think its render Githubissues.

  • Githubissues is a development platform for aggregating issues.