# Embedding on NextJS - Stuck on Loading and constant iframe refresh

**URL:** https://meta.discourse.org/t/embedding-on-nextjs-stuck-on-loading-and-constant-iframe-refresh/179351
**Category:** Support
**Tags:** unsupported-install
**Created:** [February 11, 2021, 3:14pm UTC](https://meta.discourse.org/t/embedding-on-nextjs-stuck-on-loading-and-constant-iframe-refresh/179351 "2021-02-11T15:14:00Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![vitor.medeiro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vitor.medeiro/32/209300_2.png) [@vitor.medeiro](https://meta.discourse.org/u/vitor.medeiro)
#### Post date: [February 11, 2021, 3:14pm UTC](https://meta.discourse.org/t/embedding-on-nextjs-stuck-on-loading-and-constant-iframe-refresh/179351/1 "2021-02-11T15:14:01Z")

</div>

Hi Support Team!

I’m a developer from Brazil and i starter a company blog on [NextJS](https://nextjs.org/), a server that handle SSR content for React. I’m trying to use discourse as a comment system for my blog, but i’m having a tough time on it.

I’m actually using the [bitnami docker discourse image](https://github.com/bitnami/bitnami-docker-discourse).

The embed javascript file needed for load the iframe is downloading normally, but the iframe stuck at  
`Loading Discussion`.  
I’m currently using the following window object:

```
DiscourseEmbed = {
    discourseUrl: 'https://comments-valelabs.domain.com.br/',
    discourseEmbedUrl: 'https://valelabs.domain.com.br/post/${slug}',
    discourseReferrerPolicy: 'no-referrer-when-downgrade'
}

```

where `slug` is the current url of my blog post.

After 10-20 seconds of loading, it throws an error to `console`:

`Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://comments-valelabs.domain.com.br') does not match the recipient window's origin ('https://valelabs.domain.com.br')`

I noticed that my iframe refreshed and changed the `referer-policy` to `strict-origin-when-cross-origin`, maybe it’s the cause of the error above.

Can anybody help me? Thanks for your time!

---

<div class="post-metadata">

### Author: ![Keith\_Hon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/keith_hon/32/262949_2.png) [@Keith\_Hon](https://meta.discourse.org/u/Keith_Hon)
#### Post date: [June 7, 2022, 2:53pm UTC](https://meta.discourse.org/t/embedding-on-nextjs-stuck-on-loading-and-constant-iframe-refresh/179351/2 "2022-06-07T14:53:16Z")

</div>

Could you provide minimal reproduction codes?
