diff --git a/covas_mobile/lib/MyHomePage.dart b/covas_mobile/lib/MyHomePage.dart index fd0b205..869e823 100644 --- a/covas_mobile/lib/MyHomePage.dart +++ b/covas_mobile/lib/MyHomePage.dart @@ -8,6 +8,8 @@ import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; import 'package:shared_preferences/shared_preferences.dart'; +import 'variable/globals.dart' as globals; + void main() { runApp(const MyApp()); } @@ -65,7 +67,7 @@ class _MyHomePageState extends State with ShowErrorDialog { String former = ""; if ((user.isNotEmpty) && (jwt.isNotEmpty)) { - var urlGet = Uri.parse("http://localhost:8083/api/users"); + var urlGet = Uri.parse("http://${globals.api}/users"); var responseGet = await http .get(urlGet, headers: {HttpHeaders.cookieHeader: '${jwt}; ${user}'}); diff --git a/covas_mobile/lib/main.dart b/covas_mobile/lib/main.dart index c277981..cb1cd48 100644 --- a/covas_mobile/lib/main.dart +++ b/covas_mobile/lib/main.dart @@ -9,6 +9,8 @@ import 'MyHomePage.dart'; import 'classes/alert.dart'; +import 'variable/globals.dart' as globals; + void main() { runApp(MyApp()); } @@ -32,7 +34,7 @@ class _LoginDemoState extends State with ShowErrorDialog { TextEditingController inputPseudo = TextEditingController(); TextEditingController inputPassword = TextEditingController(); Future _login(BuildContext context) async { - var url = Uri.parse("http://localhost:8083/api/token"); + var url = Uri.parse("http://${globals.api}/token"); var pseudo = inputPseudo.text; var password = inputPassword.text; if ((pseudo.isNotEmpty) && (password.isNotEmpty)) { @@ -125,7 +127,7 @@ class _LoginDemoState extends State with ShowErrorDialog { var jwt = prefs.getString("jwt") ?? ""; var user = prefs.getString("user") ?? ""; if ((jwt.isNotEmpty) && (user.isNotEmpty)) { - var urlToken = Uri.parse("http://localhost:8083/api/token"); + var urlToken = Uri.parse("http://${globals.api}/token"); var responseToken = await http.get(urlToken, headers: {HttpHeaders.cookieHeader: '${jwt}; ${user}'}); diff --git a/covas_mobile/lib/variable/globals.dart b/covas_mobile/lib/variable/globals.dart new file mode 100644 index 0000000..98b9df8 --- /dev/null +++ b/covas_mobile/lib/variable/globals.dart @@ -0,0 +1 @@ +String api = "10.0.2.2:8083/api";