❔ Make my api accessible

If we create a webapi using the dotnet new webapi template, the api is accessible using two different urls: https://localhost:port and http://localhost:port. How to make it accessible through my private ip address rather than localhost? I wanna call https://myprivateip:port.
13 Replies
Pobiega
Pobiega2y ago
just for testing purposes or more long-term? and do you want access only within your local network, or outside internet access?
Florian Voß
Florian VoßOP2y ago
the api only has a single endpoint that returns "success" or "fail", its not a productive api. The purpose of the project is to have a communication over the nethwork with an esp32-eye board. I wanna send post request from the esp32-eye board when a button is pressed to my api therefore my api has to be accessible for the board
Pobiega
Pobiega2y ago
That doesnt answer my questions.
Florian Voß
Florian VoßOP2y ago
either is fine i suppose private network is easier so lets stick to that
Pobiega
Pobiega2y ago
if you open up "launchSettings.json" you should see the applicationUrl listed there change from "localhost" to "0.0.0.0" and it will listen on all interfaces, meaning it will be as accessible as it can
Florian Voß
Florian VoßOP2y ago
oh so it will react to anyPrivateIP:Port?
Pobiega
Pobiega2y ago
that should be enough for local network access. For outside internet access, you will need port forwarding (if using a router) yeah it will bind to all available interfaces localhost is a special network interface called "loopback" ie, localhost is available even if your computer doesnt even have a network card at all
Florian Voß
Florian VoßOP2y ago
gonna try that, thank you very much @Pobiega I have launch.json and I have appsettings.json but I do not have launchsettings.json do i have to create that file myself?
Pobiega
Pobiega2y ago
what .NET version? but no, you shouldn't have to. it really should be there :p
Pobiega
Pobiega2y ago
Florian Voß
Florian VoßOP2y ago
oh under properties, I do have it thx
Pobiega
Pobiega2y ago
if 0.0.0.0 doesnt work, try https://+:port or * (instead of +), the documentation lists all 3 in various places * seems to be recommended
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server