encoredev / encore

Development Platform for building robust type-safe distributed systems with declarative infrastructure

Home Page:https://encore.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Javascript generated client triggers errors on User-Agent in browser

rewop opened this issue · comments

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

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 I should have a PR today or tomorrow.