Skip to content

Commit c27bc96

Browse files
authored
Add proper user agent to instance check (#48)
1 parent 69441b6 commit c27bc96

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "evcc",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"main": "node_modules/expo/AppEntry.js",
55
"scripts": {
66
"start": "expo start",

screens/MainScreen.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Linking, ActivityIndicator, StyleSheet, Animated } from "react-native";
1010
import { Text, Layout, Spinner, Button } from "@ui-kitten/components";
1111
import { useAppContext } from "../components/AppContext";
1212
import { useTranslation } from "react-i18next";
13+
import { USER_AGENT } from "../utils/constants";
1314

1415
function LoadingScreen() {
1516
return <ActivityIndicator size="large" />;
@@ -142,7 +143,7 @@ export default function MainScreen({ navigation }) {
142143
ref={webViewRef}
143144
overScrollMode="never"
144145
setBuiltInZoomControls={false}
145-
applicationNameForUserAgent={"evcc/0.0.1"}
146+
applicationNameForUserAgent={USER_AGENT}
146147
onError={onError}
147148
onHttpError={onHttpError}
148149
onLoad={onLoad}

utils/constants.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { version } from "../package.json";
2+
3+
export const USER_AGENT = `evcc/${version}`;

utils/server.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import axios, { AxiosError } from "axios";
22
import { t } from "i18next";
3+
import { USER_AGENT } from "./constants";
34

45
export function cleanServerUrl(url) {
56
let result = url.trim();
@@ -14,7 +15,10 @@ export function cleanServerUrl(url) {
1415

1516
export async function verifyEvccServer(url, authOptions) {
1617
try {
17-
options = { timeout: 10000 };
18+
const options = {
19+
timeout: 10000,
20+
headers: { "User-Agent": USER_AGENT },
21+
};
1822
if (authOptions) {
1923
const { username, password } = authOptions;
2024
options.auth = { username, password };

0 commit comments

Comments
 (0)