Ionic http.request ERR_UNKNOWN_URL_SCHEME

I am developing a simple android app using Ionic Framework where at some point I’m using this.http.get('https://somedomain.com').

Testing locally with ionic serve everything works, but on device it fails to load.

On the debug log the message is net::ERR_UNKNOWN_URL_SCHEME and I believe its because the protocol is being changed from https:// to intent:// and I don’t know why.

My code is:

this.http.get('https://somedomain.com')

and the error is:

intent://www.somedomain.com/path/2345435#Intent;scheme=https;package=com.net…ps%3A%2F%2Fwww.somedomain.com%2Ftitle%2345435%3FpreventIntent%3Dtrue;end:1
GET intent://www.somedomain.com/title/2345435
net::ERR_UNKNOWN_URL_SCHEME

Hi,

I suspect you might have a missing access origin setting in your config.xml???

Something like…

<access origin="*" />

Will allow everything - then you can restrict after that if required.

No, it is there.

I have also (re)installed cordova-plugin-whitelist and added the lines bellow to AndroidManifest.xml, but nothing seems to fix it.

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

Is it the expected behavior? Does the framework replaces http:// with intent://?

What “device” are you talking about? What platform?

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.

I’m curious whether we’re dealing with the ordinary Angular Http or the native HTTP here.

@Sujan12, I’m testing in an Android device.
And, yes. I got the error net::ERR_UNKNOWN_URL_SCHEME debugging from chrome device inspector.

@rapropos, I’m using Angular http:

import { Http, Request, RequestMethod } from '@angular/http';

So you put in http://... and it then loads something starting with intent://... - that looks like Android being smart and opening the app connected to that domain.

Here is a way to handle this natively:


Maybe this gives you a new idea.

I faced the ERR_UNKNOWN_URL_SCHEME error while using http.request in Ionic. In my case, it was caused by trying to open a link that used a custom scheme like intent:// instead of http:// or https://. I fixed it by making sure all URLs passed to the WebView or HTTP client used standard web protocols (http or https) only. That stopped Android from trying to handle it as an app intent. The error can be triggered by several factors, which can be broadly categorized into issues related to custom URL schemes, browser compatibility, extensions, and typos.

There are many ways to fix the error, you need to understand in detail. I hope it helps!

The ERR_UNKNOWN_URL_SCHEME error in Ionic usually means the app is trying to access a URL with an unsupported or incorrect scheme, which can happen with both Angular’s HttpClient and the native HTTP plugin. Double-check that you’re using a full valid URL (like https:// or http://), as some HTTP plugins don’t support custom or file schemes. Also, make sure your AndroidManifest.xml includes the right intent filters for the schemes you need.

For a more detailed breakdown of causes and step-by-step troubleshooting tips, this resource provides a clear guide: https://sslinsights.com/fix-err_unknown_url_scheme-error/.

I hope it can help you!