Julious Igmen
Julious Igmen

Reputation: 278

Android - couldn't access API that is under a subdomain

I have a local API service that is under a sub domain:

http://sub.192.168.1.1/api/endpoint

By adding the IP redirect to my machine's Hosts file, I can test and consume the API well when using browser tools like Postman, and even opening them via the browser itself (some don't have security at all and just returns plain JSON). Now I tried adding the IP redirect to my device's hosts file too so it can access the subdomain as well as my dev machine. All goes well and I can directly access the APIs via the browser, but when using the app, the endpoints can't be found.

I'm using Retrofit with OkHttp as of now. Hoping anyone can shed a light with this problem.

Upvotes: 0

Views: 439

Answers (1)

Gent
Gent

Reputation: 6425

Did you try at retrofit object to add slash at the end of URL?

.baseUrl("http://sub.192.168.1.1/api/endpoint/")
.build();

Upvotes: 2

Related Questions