encore icon indicating copy to clipboard operation
encore copied to clipboard

Javascript generated client triggers errors on User-Agent in browser

Open rewop opened this issue 1 year ago • 2 comments
trafficstars

Description of the Problem

While learning encore.dev using the uptime tutorial I found out the frontend client generates the following errors in the browser console

Refused to set unsafe header "User-Agent"

The error is thrown because the generated js client attempts to set the User-Agent and the browser doesn't allow it.

Expected Behavior

Generated JS client for browser should not attempt to set User-Agent. User-Agent should be only set when the client is used in backend services.

Environment

  • Mac Sonoma 14.2.1
  • Chrome 120.0.6099.234

rewop avatar Jan 29 '24 21:01 rewop

Thanks @rewop. We don't have a good way of distinguishing between client generation for frontend use and for backend use at the moment, but until we do it's a better default to not send the User-Agent header. Want to submit a PR?

eandre avatar Feb 09 '24 16:02 eandre

@eandre I should have a PR today or tomorrow.

rewop avatar Feb 12 '24 08:02 rewop