Search This Blog

Tuesday, September 1, 2020

react native axios/fetch fails

If your requests are going as network errors for whatever you do and not able to 
get it working on RN >60

Try to tell android manifest that you need a network config.


android:networkSecurityConfig="@xml/network_security_config"

Also create the xml and raw folder in resource folder of app and add the
public key of your site to the raw folder with out the extension . .
yoursite.cer should be specified as .. @raw/yoursite in your network config.




<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
  
           <domain includeSubdomains="true">yoursite address</domain>
   

        <trust-anchors>
            <certificates src="system" />
            <certificates src="user" />
 
       
            <certificates src="@raw/certificatefilenamewithoutextension"/>
        </trust-anchors>
    </domain-config>
</network-security-config>

No comments:

Post a Comment