feat: Support connecting to the API on localhost

This is a temporary solution, which adds an exception for 10.0.2.2,
allowing access over HTTP (without TLS). Once the app is
production-ready, it should use a publically hosted API.
This commit is contained in:
Peter Vacho 2024-12-22 23:23:02 +01:00
parent ec81d4ee12
commit 0c0839a7d8
Signed by: school
GPG key ID: 8CFC3837052871B4
3 changed files with 8 additions and 4 deletions

View file

@ -5,6 +5,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<application
android:networkSecurityConfig="@xml/network_security_config"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"

View file

@ -10,7 +10,8 @@ import android.util.Log
import okhttp3.ResponseBody
object RetrofitClient {
private const val BASE_URL = "https://90f2-213-160-184-230.ngrok-free.app"
// Points to localhost on the machine running the emulator
private const val BASE_URL = "http://10.0.2.2:8000"
private val retrofit: Retrofit by lazy {
Retrofit.Builder()

View file

@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
</PreferenceScreen>
<network-security-config xmlns:android="http://schemas.android.com/apk/res/android">
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">10.0.2.2</domain>
</domain-config>
</network-security-config>