CORS error on Chirpstack V4

Greetings,

I am facing same problem.
I am trying to communicate with ChirpStack server using Vuejs. When I send request i got CORS error:

const response = await axios.get(“http://xx.xx.xx.xx:8090/api/gateways?limit=10”, {
headers: {
‘Content-Type’:‘application/json’,
‘Accept’: “application/json”,
‘Grpc-Metadata-Authorization’: Bearer ${mytoken}
}
});

and getting below error

Access to XMLHttpRequest at ‘http://xx.xx.xx.xx:8090/api/gateways?limit=10’ from origin ‘http://localhost:5173’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

I am using chirpstack v4
I tried adding different variations of velow code to chirpstack.toml, chirpstack-gateway-bridge.toml and /etc/chirpstack-rest-api/environment (followed by corresponding service restart), but without success.

[api.cors]
allowed_origins=[“*”]
allowed_methods=[“GET”, “POST”, “PUT”, “DELETE”]
allowed_headers=[“Authorization”, “Grpc-Metadata-Authorization”, “Content-Type”]
expose_headers=[“Grpc-Metadata-Authorization”]
allow_credentials=true

Note that API itself is working fine if I try from Postman application.

I would really appreciate help here as I am stuck with my development (GW , node online status real time monitoring)

Guys, no one? :slight_smile:
I am thinking to call API from the server itself, dump the results as JSON and then push it to my monitoring platform myself. Not quite elegant solution, but I do not see any other ways now

The called server and calling server should have the same domain name.
E.g: xyz.example.com

Or have to change the CORS via proxy?

Calling server is my laptop and called server is chirpstack VPS (public access). Off course I prefer to use the chirpstack v4 API service and not reinvent the wheel, but I do not know what to change on chirpstack configuration to get over the CORS error.

Yes I am using nginx proxy ion chirpstack server side and here is the current config

This topic was automatically closed after 90 days. New replies are no longer allowed.