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

Flutter Web and the User Agent #937

Closed
g123k opened this issue Jun 5, 2024 · 1 comment · Fixed by #950
Closed

Flutter Web and the User Agent #937

g123k opened this issue Jun 5, 2024 · 1 comment · Fixed by #950
Assignees
Labels
🐛 bug Something isn't working

Comments

@g123k
Copy link
Contributor

g123k commented Jun 5, 2024

Hi everyone,

I have received several complaints about the SDK when used on the web.
Every time the error is ClientException: XMLHttpRequest error..

After digging a little bit, the real Exception is:
Refused to set unsafe header "User-Agent"

Today, the way we send the custom header on mobile and desktop is OK.
However, on the web, a User-Agent must follow a strict format.

So we have two choices here:

  • Try to create a valid header entry
  • Rename what we call "User-Agent" to another name
@g123k g123k added the 🐛 bug Something isn't working label Jun 5, 2024
@monsieurtanuki
Copy link
Contributor

@g123k AFAIR the user-agent is used by the OFF server for stats, so any change would have an impact on the server stats, cc @stephanegigandet
IMHO the easiest solution would be not to force the user-agent when used in web mode. I assume that the browser user-agent will overwrite that void, which would be a relatively relevant approximation for the OFF server. Or it will be kept null, which would also solve the current issue.
Btw we can easily detect "web" usage, we already do with code like that - we consider the "js" version as "web":

import 'uri_reader_stub.dart'
    if (dart.library.io) 'uri_reader_io.dart'
    if (dart.library.js) 'uri_reader_js.dart';

Just my 2 cents.

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

Successfully merging a pull request may close this issue.

2 participants