I want to embed the latest updates from our community on my website:
To accomplish this, I am trying to access the latest.json and will parse that appropriately and embed on my site:
I went to admin and setup the CORS origins:
I even updated app.yml with the following lines and rebuild the whole thing:
I don’t know if this is needed but it does work with this setting or without.
But still same issue as you check on this site:
Access to XMLHttpRequest at ‘https://community.schulminator.com/latest.json’ from origin ‘https://www.schulminator.com’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
I am really stuck here…
Same problem here
Has someone been able to get it work?
If anyone has a similar problem with a CORS configuration, please check that you removed the trailing slash from your link. A stupid mistake that cost me a couple of hours of my time.
I think the CORS setting tip should definitely be made clearer:
Allowed origins for cross-origin requests (CORS). Each origin must include http:// or https://. The DISCOURSE_ENABLE_CORS env variable must be set to true to enable CORS.
Allowed origins for cross-origin requests (CORS). Each origin must include http:// or https:// and no trailing slash. The DISCOURSE_ENABLE_CORS env variable must be set to true to enable CORS.
Btw, how would one make a PR for something like this? Should it change only the English locale here and the translations will be managed elsewhere (e.g. through Transifex), or should the translations be also covered by the PR?
If the trailing slash is a problem, our code should auto-remove it @sam.
@vinothkannans can you change it so we auto strip trailing slash here?