Android 안드로이드
[Android] Ionic /Capacitor 쿠키(Cookie)세션(Session) 문제 targetsdkversion 31 (Android 12)
jeongyj
2022. 9. 20. 17:37
이번에 안드로이드 앱 출시시 대상 API 수준 요구사항이 12로 올라가서 버전을 맞춰주었다.
targetSdkVersion 을 맞춰주고 IntentFilter의 exported 명시적 선언 이 필요하다고 해서
manifest.xml에 android:exported="false" 추가
했으나.. 쿠키/ 세션으로 로그인 관리를 하고있었는데 계속 적용이 안됐다. 공식 문서를 살펴보니
쿠키관련 내용은 SameSite 동작테스트 관련 내용
좀더 찾아보니 쿠키관련 셋팅을 해줘야 하는것 같다
document.cookie = 'same-site-cookie=foo; SameSite=Lax';
document.cookie = 'cross-site-cookie=bar; SameSite=None; Secure';
참고 - https://www.hahwul.com/2020/01/18/samesite-lax/
설정 시도는 못해봤으니 결국 https 로맞춰야한다는 자료를 찾음..
Android Manifest 파일에 Application 탭 내에 다음과 같이 추가하는 방법으로 로그인이 되게는 해봤지만 이상하게 웹뷰 형태가 아닌 웹 형태로 앱이 실행됨 (android:usesCleartextTraffic="true" 로 하면 http 사용 가능)
<application
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:usesCleartextTraffic="true">
Capacitor 는 연결 url CapacitorConfig 에서 설정
원래 hostname을 사용했지만 자동으로 http 가 붙어서 연결해버림 기존 개발자가 왜 hostname 을 썻는지 모르겠지만
url 로 https 강제로 설정해서 해결했다.