Fetch local ip adress

Hello this is my first add-ons development and I have a few questions.

I have a 4g box, when i fetch my box via a specific route (http://192.168.1.1/api/monitoring/month_statistics) i get the total amount of data i have downloaded for the current month.

I want to create an extension to avoid to go to the monitoring page for checking this data.

1 - is this possible to fetch a local ip address via an add-on ?
2 - what is the solution to do that ? I found that but the code seems a bit deprecated (I have the following error on my console The object "Components" is obsolete. It will be deleted soon.).

Are you looking for the local IP of the device the extension is running on? Or do you just want to make a request to that local IP in your example? If so, you can just use that url with fetch.

Hello sorry for the late reply i have lot of work this month.

I want to fetch a script in the router 192.168.1.1/api/something for example.

But the problem is when i fetch via postman for example is ok; but when i do the same via the extension i have a CORS policy error.

I think this is because the router only authorize fetch when he come from the local network.

So the question is : it is possible to fetch this kind of “api” via a web extension ? If yes how ?

What you want to do is add a host permission for the IP of the router, so you can ignore CORS. If the IP is not hardcoded in the extension, you could just declare an optional permission of <all_urls>and then request the permission for the IP once you know it.