Niet in staat om lokale Discourse in te sluiten in lokale Ghost-instantie

AI-generated summary

nehalist is attempting to embed a local Discourse instance into a local Ghost installation, running on ports 9292 and 2368 respectively. After adding Ghost’s URL to Discourse’s allowed hosts, the embed displays “Loading discussion…” but fails with a postMessage error: “The target origin provided (‘http://localhost:9292’) does not match the recipient window’s origin (‘http://localhost:2368’).” simbleau suggests trying variations of the host entry (with/without trailing slash or wildcards), noting that the iframe may not be fully loading. codinghorror clarifies that Discourse does not support running production-like instances on non-standard ports, implying local development setups should use proper hostnames. nehalist confirms they followed the development guide and that Discourse works locally—only embedding fails. codinghorror advises testing with actual hostnames instead of ports. nehalist attempts using nginx proxies to map ghost.localhost and discourse.localhost, but encounters a new error: “Invalid target origin ‘’ in a call to ‘postMessage’.” When reverting to http://localhost:9292/ for discourseUrl, the error disappears but the embed gets stuck in an infinite “Loading discussions” loop with repeated requests. The nginx configs are minimal, forwarding traffic to the respective localhost ports with standard proxy headers.

Hey there,
I wanted to try out Discourse on a local ghost installation.

Basically I’ve set up everything in the easiest way possible; I’ve followed the “Beginners Guide to Install Discourse for Development using Docker” and set up Ghost using its CLI.

Ghost runs on localhost:2368, Discourse on localhost:9292

I’ve added localhost:2368 to the Customize/Embedding allowed hosts (without any settings like class name, path allowlist or post to category).

After adding the code snippet (and ofc properly replacing placeholders) I do have an embed of Discourse which says “Loading discussion…” - but after a few seconds logs a console error

Failed to execute ‘postMessage’ on ‘DOMWindow’: The target origin provided (‘http://localhost:9292’) does not match the recipient window’s origin (‘http://localhost:2368’).

What am I missing here?

Thanks!

(Not an expert or team)

You get that error if the iframe has not loaded.

When you added localhost:2368 to the allowed hosts, try with or without a slash at the end, as well as with wildcards.

What’s happening is that it might load the page, but none of the content which links outside of it, causing this breakdown of loading.

Nonetheless, I was actually very interested in trying out ghost soon. So I’ll watch this topic and hope this is the only issue you experience with it. :slight_smile:

Unfortunately I haven’t found a solution so far :frowning:

It sounds like you are trying to run a production instance at a non standard port? This is not supported in Discourse.

Production instance? I followed the guide the install Discourse locally for development - shouldn’t this be the proper installation for local use? The installation works flawlessly, just the embedding is causing troubles.

I think you will need to find a way to test this using actual hostnames and not ports.

Guess I’ll try to setup a proxy with nginx then, thanks.

I’ve tried adding two nginx proxies, one for Ghost and one for Discourse, running at ghost.localhost and discourse.localhost. After changing all the URLs to the proxies the error has become:

Failed to execute ‘postMessage’ on ‘Window’: Invalid target origin ‘’ in a call to ‘postMessage’.

When using http://localhost:9292/ for the discourseUrl instead of http://discourse.localhost/ there’s no more error, but the comments are stuck in an endless loop (“Loading discussions” forever and doing some requests every few seconds).

The nginx configurations are fairly simple:

server {
  listen 80;
  server_name discourse.localhost;

  access_log /var/log/nginx/discourse.localhost-access.log;
  error_log /var/log/nginx/discourse.localhost-error.log;
  
  location / {
    proxy_pass         http://127.0.0.1:9292;
    proxy_set_header   X-Forwarded-For $remote_addr;
    proxy_set_header   Host $http_host;
  }
}

Respectively ghost instead of discourse for the ghost configuration.