admin管理员组文章数量:1208155
I am working on a dart/flutter web app with a custom back-end. Both use dart and the front-end is supposed to make an API call against the back-end which then anwsers with a redirect to an external web page.
However, when the api call is made I can see the the redirects happening in the network tab but no new page is opening. Instead the http.post (or http.head request since I tried both) does just go through all the redirects and receives a code 200 at the end. So, the page is not opening and I also cannot intercept the redirect location from the initial API response because the response I receive in the frontend is the one from the redircets which is the one with code 200 and not "Location" header.
I tried disabling automatic redirects which does not seem to work as also explained here:
How to not follow redirects with Darts http-package? request.followRedirects = false is set
Generally I also found some seemingly contradictory information:
flutter/dart http package not redirecting to page
How to get redirect url in Dart?
So, http.post follows redirects automatically but also cannot handle them apparently? And the suggestion to disable it also does not work. This leaves me quite confused as I do not see a way to open a new page this way. Preferably I would want to use universal_html to use:
html.window.open(Uri.parse(location!) as String, 'Login');
However, as mentioned previously I cannot get the location from the API call. I would also like to avoid hardcoding the address in the front-end if possible.
本文标签: flutterCan you open a new page from an API redirectStack Overflow
版权声明:本文标题:flutter - Can you open a new page from an API redirect? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738695394a2107347.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论