iOS WKWebView: Origin http://localhost:12344 is not allowed by Access-Control-Allow-Origin


#1

Anybody using WKWebView (see Drastically improving the performance of your meteor iOS app with WKWeb​View) with CollectionFS to display images successfully?

I get the following error message: Origin http://localhost:12344 is not allowed by Access-Control-Allow-Origin.

Adding App.accessRule("http://localhost:12344/*", false);in mobile-config.js does not help.


#2

@miriam7
same issue I think … I had logged here https://github.com/practicalmeteor/meteor-wkwebview/issues/6 and https://github.com/CollectionFS/Meteor-CollectionFS/issues/760 but not luck on a response yet.


#3

@miriam7 looks like this is the issue:

The worst issue is that WKWebView doesn’t allow loading files from the file (file://) protocol like UIWebView does. This is what Cordova uses internally to load files from the www folder. Using an embedded local http server to load the www folder from the http protocol circumvents this issue.

from http://plugins.telerik.com/cordova/plugin/wkwebview so we just need to work out how to get around this. I have Meteor’s webapp in my project and browser-policy but have not worked out the config settings to make this work yet.


#4

@adamgins Did you ever find a solution to this? I’m having the exact same issue, using https://github.com/serviewcare/WKWebview

Thanks!


#5

Unfortunately no. I have not tried since meteor 1.2

Btw, Would be awesome if this was part of core like the new ‘meteor add crosswalk’ :wink:


#6

My meteor App uses collectionFS and WKWebView, however the iOS App doesn’t use Cordova framework. File download and upload works as long as NO CDN, which is another issue.

When CDN is configured and turned on, then the App uploades file to CDN nodes.

If use FS.HTTP.uploadUrl = Meteor.absoluteUrl() + ‘/cfs/files’; then the upload address is corrected, however got error for “Access-Control-Allow-Origin”, which is understandable.

For me is to fix this issue…


#7

@miriam7 have you found any solution?


#8

@dhavalrajani: A fix has been merged to https://github.com/CollectionFS/Meteor-http-methods, but I don’t think a new version of the package has been published yet.


#9

what is use of this package? how it useful for file upload in IOS with wkwebview package?


#10

The Origin http://localhost:12344 is not allowed by Access-Control-Allow-Origin error that this topic is about is a result of CORS requirements. cfs:http-methods is the package CollectionFS uses to receive file uploads, and this where the header needs to be set.

This fix, together with WKWebView support in Meteor 1.3, should allow you to upload files to CollectionFS.


#11

Hello @martijnwalraven

I am getting following error after picking file from photo gallery of iPhone6

2016-03-16 19:24:55.799 SpaHack[2137:967232] ERROR: Access denied [403]
2016-03-16 19:24:55.841 SpaHack[2137:967706] METEOR CORDOVA DEBUG loading filepath: /var/mobile/Containers/Bundle/Application/049C8C3B-9EEA-4A6C-A11B-675C36960C46/SpaHack.app/www/application/images/loader.gif for path: /images/loader.gif
2016-03-16 19:24:55.842 SpaHack[2137:967706] METEOR CORDOVA DEBUG contentType: image/gif
2016-03-16 19:24:55.854 SpaHack[2137:967232] ERROR: Error: “Queue” network [undefined], errorClass@http://localhost:12344/packages/meteor.js?4dc9757b244a30bdf37a732ac4db4026ce56fb6b:558:24
http://localhost:12344/packages/cfs_upload-http.js?cf37b2941c8cdbfd85cdc3948f57fed4bb429081:379:32
http://localhost:12344/packages/cfs_upload-http.js?cf37b2941c8cdbfd85cdc3948f57fed4bb429081:105:15
http://localhost:12344/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:801:24
onreadystatechange@http://localhost:12344/packages/cfs_upload-http.js?cf37b2941c8cdbfd85cdc3948f57fed4bb429081:164:19
2016-03-16 19:24:55.887 SpaHack[2137:967232] ERROR: Error: “Queue” network [undefined], errorClass@http://localhost:12344/packages/meteor.js?4dc9757b244a30bdf37a732ac4db4026ce56fb6b:558:24
http://localhost:12344/packages/cfs_upload-http.js?cf37b2941c8cdbfd85cdc3948f57fed4bb429081:379:32
http://localhost:12344/packages/cfs_upload-http.js?cf37b2941c8cdbfd85cdc3948f57fed4bb429081:105:15
http://localhost:12344/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:801:24
onreadystatechange@http://localhost:12344/packages/cfs_upload-http.js?cf37b2941c8cdbfd85cdc3948f57fed4bb429081:164:19
2016-03-16 19:24:55.907 SpaHack[2137:967232] ERROR: Error: “Queue” network [undefined], errorClass@http://localhost:12344/packages/meteor.js?4dc9757b244a30bdf37a732ac4db4026ce56fb6b:558:24
http://localhost:12344/packages/cfs_upload-http.js?cf37b2941c8cdbfd85cdc3948f57fed4bb429081:379:32
http://localhost:12344/packages/cfs_upload-http.js?cf37b2941c8cdbfd85cdc3948f57fed4bb429081:105:15
http://localhost:12344/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:801:24
onreadystatechange@http://localhost:12344/packages/cfs_upload-http.js?cf37b2941c8cdbfd85cdc3948f57fed4bb429081:164:19
2016-03-16 19:24:55.927 SpaHack[2137:967232] ERROR: Error: “Queue” network [undefined], errorClass@http://localhost:12344/packages/meteor.js?4dc9757b244a30bdf37a732ac4db4026ce56fb6b:558:24
http://localhost:12344/packages/cfs_upload-http.js?cf37b2941c8cdbfd85cdc3948f57fed4bb429081:379:32
http://localhost:12344/packages/cfs_upload-http.js?cf37b2941c8cdbfd85cdc3948f57fed4bb429081:105:15
http://localhost:12344/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:801:24
onreadystatechange@http://localhost:12344/packages/cfs_upload-http.js?cf37b2941c8cdbfd85cdc3948f57fed4bb429081:164:19
2016-03-16 19:24:55.944 SpaHack[2137:967232] ERROR: Error: “Queue” network [undefined], errorClass@http://localhost:12344/packages/meteor.js?4dc9757b244a30bdf37a732ac4db4026ce56fb6b:558:24
http://localhost:12344/packages/cfs_upload-http.js?cf37b2941c8cdbfd85cdc3948f57fed4bb429081:379:32
http://localhost:12344/packages/cfs_upload-http.js?cf37b2941c8cdbfd85cdc3948f57fed4bb429081:105:15
http://localhost:12344/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:801:24
onreadystatechange@http://localhost:12344/packages/cfs_upload-http.js?cf37b2941c8cdbfd85cdc3948f57fed4bb429081:164:19

Can you tell me how to use this package to remove this error?

Thanks in advance


#12

From your output, it seems you are not yet running Meteor 1.3. Make sure you’ve removed any other WKWebView plugins, and update using meteor update --release 1.3-rc.2.


#13

Hello @martijnwalraven

I am using Meteor@1.1.0.3. And if i update this version it is possible that other functionality of my project wont work. Any solution for this version?


#14

WKWebView is not properly supported before Meteor 1.3, so I’m afraid updating is the only real solution.


#15

Hello @martijnwalraven

after this command meteor update --release 1.3-rc.2 i am not able to build mobile apps. I am getting following error

While adding platform Android to Cordova project:
Cordova error: Failed to fetch platform android@5.1.1
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: tunneling socket could not be established, cause=connect ETIMEDOUT
(If the error message contains suggestions for a fix, note that this may not apply to the Meteor integration. You can try running
again with the --verbose option to help diagnose the issue.)


#16

This looks like a proxy issue. Are you indeed behind a proxy server? If so, you may need to configure the HTTP_PROXY or HTTPS_PROXY environment variables.


#17

Hello @martijnwalraven Thanks for the great help :slight_smile:


#18

@martijnwalraven for me this topic is still open, see also my post on Cordova (iOS and Android) cannot connect XHR / sockjs / CORS when setting up Nginx

I am running out of idea?
Do you have any help

Thanks