NextJS 中的嵌入 - 卡在加载和持续的 iframe 刷新

大家好,支持团队!

我是一名来自巴西的开发者,正在使用 NextJS(一个为 React 处理 SSR 内容的服务器)启动公司博客。我试图将 Discourse 用作博客的评论系统,但遇到了不少困难。

目前我使用的是 bitnami 的 Discourse Docker 镜像

加载 iframe 所需的嵌入 JavaScript 文件已正常下载,但 iframe 一直卡在“正在加载讨论(Loading Discussion)”状态。

我当前使用的 window 对象如下:

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

其中 slug 是我博客文章的当前 URL。

在加载 10-20 秒后,控制台抛出以下错误:

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')

我注意到我的 iframe 刷新后将 referer-policy 更改为 strict-origin-when-cross-origin,这可能是导致上述错误的原因。

有人能帮忙吗?感谢大家的时间!

您能提供最小的可复现代码吗?