I believe you have to set
DISCOURSE_ENABLE_CORS: true
in your app.yml (somewhere in the env
section)
Shouldnāt it be setting the DISCOURSE_ENABLE_CORS variable for discourse?
Iām not sure what you are saying, but please try doing what was recommended. Iām pretty sure that you can just do a ./launcher destroy app;./launcher start app
rather than a full rebuild.
Thank you for your reply. Sorry for not being clear enough in my previous message.
Iām using Discourse hosted instance and going to embed Discourse to my website, and when I try to get contentDoument
object of the iframe of embedded Discourse, I found the cross origin limit. In admin setting page, I noticed there is the ācors originsā setting as shown in the topic picture. Then I add my testing origin url, but not worked. And I noticed the tip that is The DISCOURSE_ENABLE_CORS env variable must be set to true to enable CORS.
However, I canāt find where to set DISCOURSE_ENABLE_CORS in admin settings.
I want to know how to set DISCOURSE_ENABLE_CORS, or if my cross-domain configuration is not working, is it related to this setting.
Embedding is not my forte, but I think you would set that in /admin/customize/embedding
rather than changing the environment variable?
Thanks for your reply. I tried it but it didnāt work.
If you want us to help you need to explain what you tried in detail.
I donāt think you can do that.
There is a hidden site setting that allows embedding an iframe but I suspect that itās not available on standard or business plans. You can contact your support contact to ask.
Embedding discourse on an iframe is not officially supported.
iframe
is created by official js script. Iām using the codes that are provided on /admin/customize/embedding
, as blow:
I need to keep the embedded parts consistent with the color pattern of my website, so I have to access the iframe althogh the iframe is not created by me.
@mikeguo what is the platform of the site into which you are trying to embed your Discourse Topics?
For example, is it a Wordpress site, or a Ghost blog?
Please provide an URL to a Post on the destination site.
All I can see is this (from the screenshot of the code in your Topic above):
https://e53c-185-143-220-5.eu.ngrok.io/
So, for example, I used the āDISCOURSE_ENABLE_CORSā env variable as described in this post to display content from my Discourse forum on a page within my Ghost blogā¦
However, the feature you seem to be trying to use from your code posted above hereā¦
ā¦seems to indicate that you are trying to embed Topics from your Discourse forum AS POSTS within your external site, which is a different use case.
We need you to explain better what it is that you are trying to do hereā¦
Thank you very much for your detailed explanation.
https://algo.monster
is my website that I want to embed Discourse in. Specifically speaking,
embed Discourse in article page to display comments, and replace Cusdis
Iām using. For example,
the article https://algo.monster/problems/math-basics
, and comments:
My website
https://algo.monster
doesnāt use a blogging platform, neither Wordpress nor Ghost. My website is implemented by my own code and deployed on my own cloud server.Using the codes that are provided on
/admin/customize/embedding
, embedded Discourse are shown correctly.The problem I hope to solve by configuring
DISCOURSE_ENABLE_CORS
is as below:
This url is the one Iām using for testing and should not cause cross-origin issues.
Thank you @mikeguo ā what have you put into your script snippet for the discourseEmbedUrl where it says āREPLACE_MEā ?
To Link to existing topics than creating topics automatically, I replaced the discourseEmbedUrl param with topicId, as below:
Thanks again @mikeguo ā regrets, but this is now beyond my ability to help any furtherā¦ I hope someone else here can adviseā¦
Thank you for your help anyway