aws-amplify / aws-amplify/amplify-hosting
when use dangerouslySetInnerHTML render twice in Nextjs on Aws amplify
- Dominant language
- Dockerfile
- Stars
- 481
- Forks
- 123
- PR merge metrics
- No merged PRs in 30d
Description
### Before opening, please confirm:
- [X] I have checked to see if my question is addressed in the [FAQ](https://github.com/aws-amplify/amplify-hosting/blob/master/FAQ.md).
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-hosting/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-hosting/blob/master/CONTRIBUTING.md).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
### 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
``
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
<details>
```
# Put your logs below this line
```
</details>
### Additional information
_No response_
Contributor guide
Research direction
Start by reproducing the issue at https://coindada.com/exchanges/coinw/ with Chrome DevTools, then compare the Pages Router SSR output with View Source. Inspect the Next.js Head usage and navigation behavior for the application/ld+json script; done means the current page has one JSON-LD script and the previous page's script is removed after navigation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, nextjs
- Domain
- cloud, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100