Configuração de origens CORS não funciona

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:
DISCOURSE_ENABLE_CORS: true
DISCOURSE_CORS_ORIGIN: ‘https://www.schulminator.com/
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…

3 curtidas

Same problem here
Has someone been able to get it work?

3 curtidas

Se alguém tiver um problema semelhante com uma configuração CORS, verifique se removeu a barra final do seu link. Um erro bobo que me custou algumas horas do meu tempo. :sweat_smile:

5 curtidas

Acho que a dica sobre a configuração CORS deve ficar definitivamente mais clara:

Texto Atual

Origens permitidas para solicitações entre origens (CORS). Cada origem deve incluir http:// ou https://. A variável de ambiente DISCOURSE_ENABLE_CORS deve ser definida como true para habilitar o CORS.

Proposta de Rascunho

Origens permitidas para solicitações entre origens (CORS). Cada origem deve incluir http:// ou https:// e não ter uma barra no final. A variável de ambiente DISCOURSE_ENABLE_CORS deve ser definida como true para habilitar o CORS.

A propósito, como faria um PR para algo assim? Deve alterar apenas o locale em inglês aqui e as traduções serão gerenciadas em outro lugar (por exemplo, via Transifex), ou as traduções também devem ser incluídas no PR?

2 curtidas

Se a barra final for um problema, nosso código deve removê-la automaticamente, @sam.

6 curtidas

@vinothkannans você pode alterar para que nós removamos automaticamente a barra final aqui?

3 curtidas

Isso já foi corrigido no PR abaixo

4 curtidas