Http request not working on device


#1

hi everyone
i have some problem from 2 days ago , my requests on device not working (also google maps and lorempixel image and private server )

i checked rest api and works fine , i think this issue taken when i enabled certificate(https) on server and after deployed app to google play !

and i saw ionic web view and works fine without error on browser
also i added this option to config.xml and index.html

config.xml


    <access origin="*" />
    <gap:plugin name="cordova-plugin-sms" source="npm" />
    <access launch-external="yes" origin="tel:*" />
    <allow-navigation href="http://ionic.local/*" />
    <allow-navigation href="http://192.168.0.32:8100" />
    <allow-navigation href="http://10.254.8.95:8100" />
    <access origin="https://pinsood.com" />
    <allow-navigation href="https://pinsood.com" />
    <allow-navigation href="http://*/*" />
    <allow-navigation href="https://*/*" />
    <allow-navigation href="data:*" />

index.html


<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-eval' 'unsafe-inline' *; object-src 'self'; style-src 'self' 'unsafe-inline'; media-src *">

#2

can anyone help me ?


#3

Did you remote debug the problem on the device already?
Follow these instructions here to debug the problem in Safari dev tools:
https://ionic.zone/debug/remote-debug-your-app#ios
Follow these instructions here to debug the problem in Chrome dev tools:
https://ionic.zone/debug/remote-debug-your-app#android
Look at the console and network tabs for errors.


#4

thanks for reply

i tested this way and return me this errors

Refused to load the script 'http://maps.google.com/maps/api/js?key=AIzaSyB4VG2fbvhKtTKsVFS7xbs3R960Qio5EPI&language=fa-IR' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-inline' 'unsafe-eval'".

base64 image

index.html:1 Refused to load the image 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAHBAMAAADzDtBxAAAAD1BMVEUAAAAAAAAAAAAAAAAAAABPDueNAAAABXRSTlMUCS0gBIh/TXEAAAAaSURBVAjXYxCEAgY4UIICBmMogMsgFLtAAQCNSwXZKOdPxgAAAABJRU5ErkJggg==' because it violates the following Content Security Policy directive: "default-src *". Note that 'img-src' was not explicitly set, so 'default-src' is used as a fallback.

and for my private server return this error

Failed to load resource .              https://pinsood.com/api/v1/categories.json

but i added Content-Security-Policy why return this error , how to fix it ?


#5

This stackoverflow question might be a solution for you