问题描述
我开发了一个移动应用,该应用通过axios
连接到API。以前工作正常。但是现在由于服务器受限制,只能通过VPN访问这些API。因此,我使用移动设备连接到VPN并通过浏览器成功访问了这些API URL。但是启用了VPN后,我无法通过移动应用访问相同的API。它不允许我。因为我可以从浏览器访问它们,所以我认为VPN连接是可以的,但是我不确定(服务器不是我的任务。它属于devops)。
这是发送axios请求的方式。
return axios({
method: 'POST',url: `${URL.URL_VAR}/api/oauth/oauth/token`,headers: {
'Content-Type': 'multipart/form-data'
},data: bodyFormData
}).then(function (response) {
console.log("response" + response.status);
return response;
}).catch(function (response) {
console.log("Get login error: " + JSON.stringify(response.message));
return response;
});
这是我的manifest.xml
文件。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.campaign">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:networkSecurityConfig="@xml/network_security_config"
android:usesCleartextTraffic="true" tools:targetApi="28"
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
这是我的网络安全配置文件。
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<!-- For React Native Hot-reloading system -->
<!-- If you are running on a device insert your computer IP -->
<domain includeSubdomains="true">localhost</domain>
<domain includeSubdomains="true">mydomain.io</domain>
<trust-anchors>
<certificates src="system" />
<certificates src="user" />
</trust-anchors>
</domain-config>
<base-config cleartextTrafficPermitted="false" />
</network-security-config>
在限制使用VPN之前,所有这些工具都可以正常工作。
由于我是初学者,因此我应该寻找哪种类型的区域来解决此问题?这与该应用程序有关系吗?还是我必须在服务器中进行任何更改?请帮忙。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)