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

Allow redirects where Access-Control-Allow-Origin header is restrictive #327

Open
hjhart opened this issue Apr 4, 2024 · 1 comment
Open

Comments

@hjhart
Copy link

hjhart commented Apr 4, 2024

Similar issue to #320, but it is slightly different.

I want to be able to handle external redirects to servers that do not have open Access-Control-Allow-Origin headers. I don't think there is a bug in the code, but I'd like to know where to hook in inside my android app to pop-up a CustomTab or something like that.

Here is an example of what I'm looking for:

Screen.Recording.2024-04-03.at.2.51.59.PM.mov

The external redirect works when it goes to https://turbo.hotwired.dev because of it's open Access-Control-Allow-Origin header.

~ ❱ curl -I https://turbo.hotwired.dev                                                                                                                                                                                                                                                                                                                            13:43:19
HTTP/2 200
...
access-control-allow-origin: *
...

The important bit in those headers is that access-control-allow-origin is set to allow all domains. But how should the turbo-android package handle it if we don't have access to set those headers (on, say, a third-party provider)? One option is to set up a proxy, but I'd love to avoid setting up any new infrastructure, as this works perfectly fine in a browser.

I'm working off of main on turbo-android (version 7.1.2), and using this server running locally: https://github.com/hjhart/turbo-native-demo

I think I should be breaking out of turbo, but I don't seem to have the proper hooks firing to do so (shouldNavigateTo doesn't fire, for instance).

Any input?

cc @jayohms I created a new issue since the previous issue was addressed and closed!

@hjhart
Copy link
Author

hjhart commented Apr 5, 2024

Something I'm playing around with on my project (that is working) right now is having a erb file that does this:

File below: members/formstack/_special_android_redirect.html.erb

Redirecting you to: <%= location %>
<script type="text/javascript">
  window.location = "<%= location %>";
</script>

And instead of redirect_to location in the rails controller I am instead doing:

render partial: "members/formstack/special_android_redirect", locals: {location: location}

Right now there is a problem going back after navigating to the redirect location, but it'll likely be an easier solve for me.

If anyone has any insight into this, it's very welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant