CORS ERROR

114 views
Skip to first unread message

Oscar Piñeros

unread,
Aug 16, 2023, 8:11:18 PM8/16/23
to Wazuh mailing list
Hello Wazuh Team,

I have an angular web application that access wazuh API Rest to get agent inventory information (name, ip, cpu, etc..), I am getting information from some endpoints (/syscollector/<id>/hardware) without problems, but in a particular endpoint (GET /agents) I have a CORS ERROR, configuration it`s the same, I am authenticated succesfuly, and get the Bearer token succesfuly, I have access succesfuly with postman and curl command, but from my app don´t work. I atach the error and other screenshot with a succesfuly get.

wazuh api.log

good request from angular app:

2023/08/16 23:58:43 INFO: unknown_user 192.168.200.101 "OPTIONS /security/user/authenticate" with parameters {} and body {} done in 0.003s: 200
2023/08/16 23:58:44 INFO: userapi 192.168.200.101 "POST /security/user/authenticate" with parameters {} and body {"username": "userapi", "password": "****"} done in 1.181s: 200
2023/08/16 23:58:44 INFO: unknown_user 192.168.200.101 "OPTIONS /syscollector/001/hardware" with parameters {} and body {} done in 0.003s: 200
2023/08/16 23:58:45 INFO: userapi 192.168.200.101 "GET /syscollector/001/hardware" with parameters {} and body {} done in 0.473s: 200

no good request from my angular app:

2023/08/17 00:03:44 INFO: userapi 192.168.200.101 "POST /security/user/authenticate" with parameters {} and body {"username": "userapi", "password": "****"} done in 0.723s: 200
2023/08/17 00:03:44 INFO: unknown_user 192.168.200.101 "OPTIONS /agents" with parameters {} and body {} done in 0.002s: 403

good request from postman:

2023/08/17 00:05:37 INFO: userapi 192.168.200.101 "POST /security/user/authenticate" with parameters {} and body {} done in 0.306s: 200
2023/08/17 00:06:25 INFO: userapi 192.168.200.101 "GET /agents" with parameters {} and body {} done in 0.086s: 200

I would appreciate your help.

Thanks,


no error.png
CORS ERROR.png

Sebastian Dario Bustos

unread,
Aug 16, 2023, 8:50:22 PM8/16/23
to Wazuh mailing list
Hello Oscar,
Thank you for using Wazuh!!!

I've found a quick solution to a similar issue for this, basically it shows you how to create a controller in Angular.js to overcome this, just change the corresponding URL for the domain and port you mentioned, let me know if this is helpful:

Let me know.
Regards.

Oscar Piñeros

unread,
Aug 16, 2023, 9:26:24 PM8/16/23
to Wazuh mailing list
Thanks a lot Seb, but I'm not using AngularJS or Ajax, it's angular 15.

Sebastian Dario Bustos

unread,
Aug 16, 2023, 10:24:45 PM8/16/23
to Wazuh mailing list
By the way, just in case here is Wazuh's API reference, at the top of it you will find how to run curl commands against it:

Also,  here is the getting started guide to  Wazuh's API:

Let me know.
Regards.

On Wednesday, August 16, 2023 at 9:11:18 PM UTC-3 Oscar Piñeros wrote:
Reply all
Reply to author
Forward
0 new messages