Ionic version: (check one with "x")
[ ] 2.x
[X] 3.x
[ ] 4.x
I'm submitting a ... (check one with "x")
[X] bug report
[ ] feature request
Current behavior:
'HTTP: Response with status: 0 for URL: null' on every request.
Expected behavior:
Working HTTP requests.
Steps to reproduce:
Run the app from Xcode on a simulator or real device.
Everything works on Android or in a browser.
I'm trying to get json from an Azure Web App in HTTPs.
No proxies set up.
Cordova whitelist installed.
The project was created a week ago with the Ionic CLI.
Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.13.1
ionic (Ionic CLI) : 3.13.1
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
@ionic/app-scripts : 3.0.0
Cordova Platforms : ios 4.5.2
Ionic Framework : ionic-angular 3.7.1
System:
ios-deploy : 1.9.2
Node : v6.11.4
npm : 5.4.2
OS : macOS Sierra
Xcode : Xcode 9.0 Build version 9A235
Misc:
backend : pro
Hello! Thank you for opening an issue with us!
The Ionic Framework issues list is designated for the reporting of bugs with the Ionic Framework or for requesting new features. As this seems like more of a support question I am going to close this issue.
I urge that you ask this question on our forum or on our slack channel.
My best guess is that CORS issues are not being handled entirely. See this document for more details: http://ionicframework.com/docs/wkwebview/#cors
If it turns out that your issue is due to a bug in the Ionic Framework, please let me know and provide a sample application via GitHub that can be used to duplicate the issue for debugging purposes and I will be happy to reopen this issue.
Thanks for using Ionic!
Is this happening on login? Check if it is one of yourr staging/development services protected by your IT team from external requests.
In my case the error was thrown when I was logging into a service, which was unavailable for any requests outside local network. Silly mistake of mine.
The staging service was available in my office only, and I was connecting to it using office WiFi. It was working in both browser and emulator during debugging, and did not work via mobile network (local IT restrictions).
As soon as I was trying to login to the service outside my office I got the error: Response with status: 0 for URL: null.
It Seems Internet issue with your application.
The response issue occurs when your wifi or internet connection is off.
otherwise, on the real device, it's CORS issue.
for brief knowledge on CORS see this: http://blog.ionicframework.com/handling-cors-issues-in-ionic/
Yes, it was a CORS issue with iOS WKWebView. Enabling CORS from localhost:8080 on my server solved the issue.
Same issue in only IOS I try to add CORS on server.
Web Browser and android work perfectly but in IOS its not work and give error Response with status: 0 for URL: null
Any solution?
I Tried I changed the web view option of my ionic app.
WKWebView ===> UIWebView
but not work..
Please help me
same issue
Same Issue
Enabling CORS from localhost:8080 in the server solve the issue. If you are sending an authorized request (JWT for example) add "withCredentials = true" in the header.
@matteobortolazzo already enabled for all origins also added withCredentials=true;
I am using .net Core 2.0 and here is my code for CORS
ConfigureServices :
services.AddCors(options =>
{
options.AddPolicy("CorsPolicy",
builder => builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
});
Configure :
app.UseCors("CorsPolicy");
Still same issue for HTTPS sites
also when I use http it's work but when change it to https its does't work.
@kanji-keraliya I was using .NET Core 1.1 and this is my code
// ConfigureServices
services.AddCors();
// Configure
app.UseCors(
builder => builder
.WithOrigins("http://localhost:8080", "https://localhost:8080")
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
@matteobortolazzo Does it working with this code?
@kanji-keraliya yes
@matteobortolazzo I tried your code in .net Core 2.0 but no luck
got the same issue. I'm using .net Core 2.0 for my API. CORS also enabled. It's working on the browser and simulator but not in real device (Iphone and Ipad).
I solved the issue by hosting my api in azure. When deploying to IOS device, it expect the api must be secured (https). So therefore, using the unsecured http protocol won't work.
I still can not find a solution for this problem. I enabled CORS in NGINX:
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, DELETE';
add_header 'Access-Control-Allow-Headers' 'Accept,Accept-Language,Content-Language,Content-Type';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
And I'm using HTTPS. I only got this problem with IOS.
Ionic proxy is working with browser and the https request is working as it should be on android.
Anyone have a tip of how can I solve this issue?
@marceloimg93 Your API (server) must be hosted with secured HTTPS protocol. Your API URL must be on this format https://server.com/api
@gadjetboi Thank you for your answer! I'm actually using https. I got a valid ssl certification from letsencrypt.org.
Also tried to remove the IOS platform folder inside ionic project and re-add it from CLI and nothing!
The only way I figured out to work was to Downgrading to UIWebView.
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Most helpful comment
Same issue in only IOS I try to add CORS on server.
Web Browser and android work perfectly but in IOS its not work and give error Response with status: 0 for URL: null
Any solution?
I Tried I changed the
web viewoption of my ionic app.WKWebView ===> UIWebView
but not work..
Please help me