본문 바로가기
Flutter

[Flutter] Insecure http is not allowed by platform 해결방법

by 유저혀 2021. 4. 14.
반응형

HTTPS 요청이 아닌  HTTP 요청으로 connection을 하게 되면 아래와 같은 에러를 보게 된다.

 

Insecure HTTP is not allowed by platform

 

해결 방법으로는 다음과 같다.

 

1. HTTPS를 사용한다

HTTPS를 지원하는 URL 요청일 경우 HTTP -> HTTPS로 변경하여 요청한다.

 

 

 

2. HTTP를 그대로 사용하는 방법

Android API 28 이상, iOS 9 이후부터 기본적으로 HTTP connection을 비활성화 해놓았다.

HTTP를 사용하려면 다음과 같은 작업이 필요하다.

 

(1) Android

$project_path\android\app\src\main/AndroidManifest.xml 파일을 열어 다음과 같은 코드를 추가한다

 

android:useCleartextTraffic="true"

 

   <application
        android:label="프로젝트명"
        android:icon="@mipmap/ic_launcher"
        android:usesCleartextTraffic="true">

 

 

(2) iOS

Info.plist파일에 하단 코드를 붙여넣는다.

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

 

 

 

728x90

댓글