Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

window.CDV_ASSETS_URL is undefined, leading to nothing being proxied #5

Closed
mattdsteele opened this issue Mar 3, 2021 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@mattdsteele
Copy link

mattdsteele commented Mar 3, 2021

Describe the bug

See my comment in #3 for more details.

Environment: in a new Cordova application (built with cordova create) and these plugins installed:

    <plugin name="cordova-plugin-webview-proxy" spec="0.0.3" />
    <engine name="ios" spec="^6.2.0" />

I'm launching the application on an iPhone running iOS 14.4 and opening the Safari Developer Tools.

Running window.WebviewProxy.convertProxyUrl('https://example.com')); returns https://example.com, with no new protocol prefixed. As a result, requests are not proxied through this plugin, and requests to external servers fail for CORS reasons.

Investigating further, I see that window.CDV_ASSETS_URL returns undefined, which results in this line being returned: https://github.com/GEDYSIntraWare/cordova-plugin-webview-proxy/blob/master/www/WebviewProxy.js#L8

Any idea why this might be happening? I can verify that the platform is on the latest version (running cordova.platformVersion === 6.2.0).

@mattdsteele mattdsteele added the bug Something isn't working label Mar 3, 2021
@NiklasMerz
Copy link
Collaborator

Is your app running on a custom scheme? This is now part of cordova-ios (apache/cordova-ios#781). You need to set a scheme and hostname in config.xml to make your app run on let's say app://myapp instead of file://index.html and this proxy just works with the custom scheme.

We might need to document this in the documentation for cordova-ios.

@mattdsteele
Copy link
Author

mattdsteele commented Mar 3, 2021

Yup, that was the issue! I've added a custom scheme in my config.xml

        <allow-navigation href="cdv://*" />
        <preference name="scheme" value="cdv" />
        <preference name="hostname" value="foobar" />

And I'm able to proxy requests now; the requests now have a prefix of cdv://foobar/_https_proxy_

I am still not seeing cookies being sent, but I'll focus that on the original #3 ticket.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants