# Is it possible to test Discourse Embed comment on localhost?

**URL:** <https://meta.discourse.org/t/is-it-possible-to-test-discourse-embed-comment-on-localhost/42724>\
**Category:** Product Support\
**Created:** [2016 年 4 月 18 日午前 11:25 UTC](https://meta.discourse.org/t/is-it-possible-to-test-discourse-embed-comment-on-localhost/42724 "2016-04-18T11:25:48Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![thangngoc89](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thangngoc89/32/115436_2.png) [@thangngoc89](https://meta.discourse.org/u/thangngoc89)\
**Post date:** [2016 年 4 月 18 日午前 11:25 UTC](https://meta.discourse.org/t/is-it-possible-to-test-discourse-embed-comment-on-localhost/42724/1 "2016-04-18T11:25:48Z")

</div>

I’m testing Discourse Embed comment system for my static blog using React locally but I can’t get it to work. I’m sure that I read [the instruction](https://meta.discourse.org/t/embedding-discourse-comments-via-javascript/31963) like 10 times. So I’m thinking that localhost should be the blocker here.

Set up :

- A fake domain `cpp.dev` in `/etc/hosts` to for routing to localhost. Let’s say it’s `cpp.dev`

- Discourse : Using vagrant with latest commit from Github.

- My website is running at `http://cpp.dev:3000`

- I added both `cpp.dev:3000`and `cpp.dev` to hosts list in Admin \> Customize \> Embedding section

- Website embed code:

```js
DiscourseEmbed = {
  discourseUrl: "http://cpp.dev:4000/",
  discourseEmbedUrl: window.location,
}

```

Looking good, now let’s run it. It shows up an iframe with `loading discussion` forever.

- In terminal, I see this message:

```plaintext
I, [2016-04-18T07:24:10.751058 #25645] INFO -- : Processing by EmbedController#comments as HTML
I, [2016-04-18T07:24:10.784677 #25645] INFO -- : Parameters: {"embed_url"=>"http://cpp.dev:3000/dnh-cpp/cpp-co-ban/0-gioi-thieu-tong-quan/0-0-gioi-thieu-ve-khoa-hoc/"}
D, [2016-04-18T07:24:10.807149 #25645] DEBUG -- : User Load (5.1ms) SELECT "users".* FROM "users" WHERE "users"."auth_token" = '951c06ee26073030dc3cf264e80804fa' LIMIT 1 [["auth_token", "951c06ee26073030dc3cf264e80804fa"]]
D, [2016-04-18T07:24:10.866750 #25645] DEBUG -- : (3.6ms) SELECT "topic_embeds"."topic_id" FROM "topic_embeds" WHERE (lower(embed_url) = 'http://cpp.dev:3000/dnh-cpp/cpp-co-ban/0-gioi-thieu-tong-quan/0-0-gioi-thieu-ve-khoa-hoc')
I, [2016-04-18T07:24:10.917468 #25645] INFO -- : Rendered embed/loading.html.erb within layouts/embed (0.9ms)
I, [2016-04-18T07:24:10.987482 #25645] INFO -- : Completed 200 OK in 186ms (Views: 61.0ms | ActiveRecord: 8.7ms)

```

- In browser console, I see this

```plaintext
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('http://cpp.dev:4000') does not match the recipient window's origin ('http://cpp.dev:3000').

```

- No new topic was created.

- Some suspicious log as `/logs/

```plaintext
	
Started GET "/dnh-cpp/cpp-co-ban/0-gioi-thieu-tong-quan/0-0-gioi-thieu-ve-khoa-hoc/" for 127.0.0.1 at 2016-04-18 07:29:25 -0400
6:29 pm
Permalink Exists (1.1ms) SELECT 1 AS one FROM "permalinks" WHERE "permalinks"."url" = 'dnh-cpp/cpp-co-ban/0-gioi-thieu-tong-quan/0-0-gioi-thieu-ve-khoa-hoc' LIMIT 1 [["url", "dnh-cpp/cpp-co-ban/0
6:29 pm
ActionController::RoutingError (No route matches [GET] "/dnh-cpp/cpp-co-ban/0-gioi-thieu-tong-quan/0-0-gioi-thieu-ve-khoa-hoc") /var/lib/gems/2.2.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware

```

Where is the wrong part in my setup ? Any help would be appriciated.

---

_[View the full topic](https://meta.discourse.org/t/is-it-possible-to-test-discourse-embed-comment-on-localhost/42724)._
