Hi !
I’m trying to send data in a smart action to a webhook. The smart action is working well so far but I can’t send data to the webhook, because of a CORS issue.
Another user had the exact same problem as me (see following thread), and I followed the instructions, but the CORS error is still there.
I’ve correctly added CORS_ORIGINS=http://app.forestadmin.com in my .env file. Here is the error:
Access to XMLHttpRequest at 'https://webhook.site/5bd9b4d2-8804-4412-9baf-463289675b1f' from origin 'http://app.forestadmin.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
Here is my smart action in forest/phase.js
collection('phase', {
actions: [{
name: 'Activate phase'
}],
fields: [],
segments: [],
});
The webhook called in routes/phase.js
router.post('/actions/activate-phase', permissionMiddlewareCreator.smartAction(), (req, res) => {
// Learn what this route does here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#delete-a-list-of-records
res.send({
webhook: { // This is the object that will be used to fire http calls.
url: 'https://webhook.site/5bd9b4d2-8804-4412-9baf-463289675b1f', // The url of the company providing the service.
method: 'POST', // The method you would like to use (typically a POST).
headers: { },
body: { // A body to send to the url (only JSON supported).
someDatas: 'some_datas',
},
},
});
});
Context
- Package Version: 3.4 (not sure about that one, I took the version inside the docker-compose file)
- Express Version: ~4.17.1
- Sequelize Version: ~5.15.1
- Database Dialect: postgresql
- Database Version:
- Project Name: traderlift-backoffice