403 Error Embedding Comments


(Dean Peterson) #1

I am able to embed comments in my application. However, the first time a new page comes up that has to generate a new topic, I get a 403 error. I have tried everything. I enabled CORS, I fixed the same origin x frame issue with a plugin and I made sure my allowed host is correct. What am I doing wrong?

VM1775 comments?embed_url=http%3A%2F%2Ftrade.abecorn.com%2F%23%2Ftradeentry%2F5713977……:75 GET tradeClient 403 (Forbidden)(anonymous function) @ VM1775 comments?embed_url=http%3A%2F%2Ftrade.abecorn.com%2F%23%2Ftradeentry%2F5713977……:75
comments?embed_url=http%3A%2F%2Ftrade.abecorn.com%2F%23%2Ftradeentry%2F5713977…:217 Uncaught TypeError: Cannot read property ‘forEach’ of undefined(anonymous function) @ comments?embed_url=http%3A%2F%2Ftrade.abecorn.com%2F%23%2Ftradeentry%2F5713977…:217
_application-9ca7d98….js:16690 Uncaught TypeError: Cannot read property ‘highlighted_languages’ of undefined


discourseEmbed, does not match recipient window origin
[solved] Error Embedding
(Dean Taylor) #2

This may be something to do with your Discourse instance not being public.


(Dean Peterson) #3

But when I hit refresh, the comments load OK. It is just the first time hitting a new page I get the 403. So because I have people log in right away there is no way around the initial 403 error?


(Dean Peterson) #4

I just tried making it public. I get the same 403 error unfortunately.


(Dean Peterson) #5

Ok, now it’s working but it takes a long time to load and I see this in the console logs:

Failed to execute ‘postMessage’ on ‘DOMWindow’: The target origin provided (‘http://discourse.abecorn.com’) does not match the recipient window’s origin (‘http://trade.abecorn.com’).

If I hit refresh right away when it says “loading discussion…” it will load instantly.


(Dean Taylor) #6

Visiting http://discourse.abecorn.com still redirects me to an authentication page - I would expect to be able to see Discourse live there.


(Dean Peterson) #7

I re-enabled authentication since it didn’t seem to help. It is working now. I added a bunch of allowed embedded urls: auth.abecorn.com, discourse.abecorn.com, abecorn.com www.abecorn.com and of course trade.abecorn.com. It takes a long time to load but I no longer get the 403 error. I see this in the console though: “Failed to execute ‘postMessage’ on ‘DOMWindow’: The target origin provided (‘http://discourse.abecorn.com’) does not match the recipient window’s origin (‘http://trade.abecorn.com’).” Since the comments eventually load, I am not overly concerned. However, it takes about 20 seconds after sitting at “loading discussion…” for the comments to appear the first time on a new page. If I hit refresh right away, they load instantly.


(Dean Taylor) #8

Start by removing the authentication wall you have setup and ruling it out completely. Try it in an incognito window.


(Dean Peterson) #9

Since it’s mostly working I’ll have to live with it for now. I have a feeling it has something to do with authentication, not on discourse, but on the page comments are being embedded. I have amore pressing matter right now.

I have an angularjs app secured with keycloak. It’s a single page app, I need to figure out how to dynamically change the page title outside the ng-view tag. When a route changes the url, the surrounding html including the title stay the same so all the titles of my topics are the same. When I tackle that problem, I’ll have to come back to this. Thanks for the help.