framework7io / framework7

Full featured HTML framework for building iOS & Android apps
http://framework7.io
MIT License
18.13k stars 3.23k forks source link

getJSON and get don't work with WkWebView #2011

Closed SpiderNeo1 closed 6 years ago

SpiderNeo1 commented 6 years ago

This is a (multiple allowed):

What you did

I Added WKWebViewEngine to my Cordova App https://github.com/apache/cordova-plugin-wkwebview-engine

Expected Behavior

With UIWebView, simple navigation is working And the call to the functions $$.getJSON and $$.get also works.

Actual Behavior

With WKWebView, simple navigation is working BUT the call to the functions $$.getJSON and $$.get no't working. I imagine that post and ajax functions don't work with WKWebView.

nolimits4web commented 6 years ago

This is because CORS policy applies. You must have correct CORS headers on server or try this plugin https://github.com/ionic-team/cordova-plugin-ionic-webview

SpiderNeo1 commented 6 years ago

Thank you for your message but I'm not on ionic. Where I have to put the good correct CORS headers ? In JS file ? In HTML file ? In the config.xml file for Cordova ?

nolimits4web commented 6 years ago

You don't have to be on ionic to use this cordova plugin

SpiderNeo1 commented 6 years ago

I just tried https://github.com/ionic-team/cordova-plugin-ionic-webview instead of https://github.com/apache/cordova-plugin-wkwebview-engine and it's still the same problem :-(

SpiderNeo1 commented 6 years ago

In fact, it works with internal file but not with WebServices.

nolimits4web commented 6 years ago

For requests to external services correct CORS headers must be set on server side https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#The_HTTP_response_headers

SpiderNeo1 commented 6 years ago

I'm sorry Vladimir but I have already put this on my server (Apache/PHP) and it doesn't work better :

header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); 
header("Content-Type: application/json");
header("Access-Control-Allow-Origin: *");
nolimits4web commented 6 years ago

Try also to add allowed methods https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods

If won’t work then check the errors in browser console

SpiderNeo1 commented 6 years ago

I can't do it at all, I tried everything...

On the Chrome browser, I have to launch the application by launching the browser in this way: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --user- data-dir = "c:/chrome"

I think I'll go back to the UIWebView. Hoping that when I re-develop my application on the F7 v2.0, everything will work fine on WKWebView.

Do you expect to release a 1.6.6 version?

SpiderNeo1 commented 6 years ago

http://uncaughterror.com/programming/ionic3/preflight-response-issue-with-ionic3-app-on-ios-build-only-resolved/

SpiderNeo1 commented 6 years ago

Maybe you should also use https://github.com/apache/cordova-plugin-whitelist No ?

SpiderNeo1 commented 6 years ago

On my Browser Chrome, I have this error :

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1' is therefore not allowed access.

lock[bot] commented 6 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.