software-mansion-labs / react-native-turbo-demo

React Native Turbo - an open source library that can bring your turbo-enabled web application into the React Native world.
MIT License
101 stars 11 forks source link

Add request headers to react-native-turbo VisitableView #216

Open lux-shaun opened 1 week ago

lux-shaun commented 1 week ago

Both turbo-ios and turbo-android support adding requests headers, as do other webviews.
Not being able to do so here is problematic for native authentication in particular, as there doesn't seem to be any way to share session information.

pfeiffer commented 1 week ago

It's not possible to set custom headers for any other requests than the initial cold boot request (in WKWebView which turbo-ios uses), as subsequent Turbo-driven requests in the WebView would have the potential to leak sensitive headers (eg. authentication headers).

For this reason, it's not supported to add custom headers for all requests, as it'd either cause potential leaking of sensitive headers or make using custom headers for eg. authentication impractical as they would only work for the initial cold boot request.

If you need to communicate something (non-sensitive!) to your backend using headers, the applicationNameForUserAgent prop can be used.

The same is true for turbo-ios and turbo-android.