Here's the situation:
I have a client application (Angular 8/Ionic 4) that is calling a API (Loopback) with a PATCH.
I listen to the "after save" hook of a certain model, which the datasource is PostgreSQL. When this hook gets triggered, I call a model that the datasource is MongoDB to perform an UpsertWithWhere operation in this MongoDB model.
The problem is that I get the following error with code 502:
Access to XMLHttpRequest at 'https://dev-api.celsoonline.com.br/api/v2/Encontros' from origin 'http://dev-aluno.celsoonline.com.br' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
So, you might think: "Missing cors configuration". But It's not. I have already configured it, in 3 different locations:
1 - server.js
const cors = require('cors')
app.use(cors())
2 - middleware.json
"cors": {
"params": {
"origin": true,
"credentials": true
}
}
3 - config.json
"remoting": {cors: true}
The MongoDB is at the Atlas server, with network access allowed to all IPs (0.0.0.0/0)
Can anyone help me on this? I'm currently working on a dev environment hosted on AWS. Running locally the error do not occur.
What am I missing?
Thanks!