adamski / RestRequest

JUCE module for making HTTP requests to REST API's
MIT License
63 stars 8 forks source link

HTTP request doesn't work on local network? #8

Open quack-master opened 7 months ago

quack-master commented 7 months ago

This is a partial code snippet from my APIClient class. I have this method 'run' triggered by a button click.

The code is working for the first 'apiURL' variable for not for the 2nd which is my own locally running API. I know my local API is fine because I can hit it with Postman and my iPhone (same network). Do you have any clue what might be happening? Thanks!

adamski::RestRequest request;
APIClient() : juce::Thread("APIClient Thread") {}
void run() override
{
    //juce::String apiUrl = "https://jsonplaceholder.typicode.com/todos/1"; //works
    juce::String apiUrl = "https://192.168.1.123:7031/get-single-anonymous"; //doesn't work

    auto response = request.get(apiUrl).execute();
    Logger::outputDebugString("response: " + response.bodyAsString);
}
ruurdadema commented 7 months ago

Does the server on your local network have SSL certificates set up? Otherwise you probably want to use http instead of https.

quack-master commented 7 months ago

Yes it was the https! The moment I used http & port 5074 (the http port for my ASP .NET server) it worked, I was quite surprised haha. I don't understand though, I'm able to hit that https endpoint in other languages like Javascript (after I setup CORS on server side) no issue. You still think the solution is set up SSL certificates on server side?

ruurdadema commented 7 months ago

It depends on your use case. If you're developing and running a local server then SSL certificates might not be needed, but if you're sending things over internet, then it's probably very good practice to do so.