로메오의 블로그

[Ionic] net::ERR_CLEARTEXT_NOT_PERMITTED 오류 해결 - Android 본문

Frontend/angular

[Ionic] net::ERR_CLEARTEXT_NOT_PERMITTED 오류 해결 - Android

romeoh 2020. 1. 16. 16:19
반응형

ionic 차례

OPTIONS http://domain.kr/portal/nn/service.do 
net::ERR_CLEARTEXT_NOT_PERMITTED

IONIC Android 최신버전에서 네트워크 통신할때 위의 오류가 발생합니다.

 

config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget id="kr.amc.aris.ctc" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    ....
    <platform name="android">
        <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
            <application android:networkSecurityConfig="@xml/network_security_config" />
            <application android:usesCleartextTraffic="true" />
        </edit-config>
        ....
    </platform>
    <platform name="ios">
        ....
    </platform>
    ....
</widget>

resources/android/xml/network_security_config.xml

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">localhost</domain>
        <domain>www.youtube.com</domain>
        <domain>api.domain.com</domain>
    </domain-config>
</network-security-config>

허용할 도메인을 모두 추가합니다.

 

Android Build

$ ionic cordova build android

 

 

ionic 차례

반응형
Comments