humhub / app

20 stars 8 forks source link

Q: Add HEADER on WebView Requests #17

Closed luke- closed 1 year ago

luke- commented 1 year ago

Is it possible to add an custom HTTP Header HUMHUB-APP on Requests made by the WebView Component?

e.g. https://stackoverflow.com/questions/66850750/flutter-webviewcontroller-how-add-header https://stackoverflow.com/questions/61482001/flutter-webview-intercept-and-add-headers-to-all-requests

I would prefer that instead of only sending a cookie with the initial request.

PrimozRatej commented 1 year ago

More about headers explained here: https://github.com/luke-/app/issues/5#issuecomment-1403340044

luke- commented 1 year ago

@PrimozRatej Hmm, I would prefer to use HTTP headers to identify Mobile App requests from the web application side. This way we could easily change rendering (e.g. extra menu points, javascript channel addon).

Would be great if you could take a look into flutter_inappwebview if it appears to be stable & reliable and supports HTTP headers.

If such HTTP header approach leads to major difficulties, we can also start with cookies for app detection.

luke- commented 1 year ago

@PrimozRatej Maybe we can use a custom UserAgent Header? https://stackoverflow.com/questions/73715018/how-to-add-custom-user-agent-to-flutter-webview

PrimozRatej commented 1 year ago

This was impl. in the scope of this #30 issue

PrimozRatej commented 1 year ago

Lucas commented I just tested the version 0.1.13 and could not see the header My-Custom-Header there. For testing, I have output all sent headers on the login page, below the login form.

But there is another header x-requested-with and value com.humhub.app. This seems to be a default header. If our custom header solution does not work, we could possibly fall back on this.

Best lucas image

PrimozRatej commented 1 year ago

It should work now: image