hathora / cloud-sdk-typescript

Hathora Cloud TypeScript SDK
https://hathora.dev/docs
MIT License
1 stars 4 forks source link

Getting spurious errors in Chrome JS console #39

Closed francislavoie closed 6 days ago

francislavoie commented 2 weeks ago

We get Refused to set unsafe header "user-agent" when using the SDK in Chrome (to call lobbyV3.listActivePublicLobbies and such).

https://github.com/hathora/cloud-sdk-typescript/blob/febd2a75966faffa79569153fab7e00d1d735945/src/sdk/lobbiesv2.ts#L64

My understanding is that this header is dependent on certain CORS rules or something like that, and browsers may complain if clobbering their built-in User-Agent header.

Would it be possible to use some other header for this, if you need to track SDK usage metric or whatever? Something like X-User-Agent or something random like that would make it not conflict with the browser, I think. If you're using it for metrics in your backend, then you could just do something like headers['X-User-Agent'] ?? headers['User-Agent'] grabbing the first defined one.

gwprice115 commented 2 weeks ago

thanks for filing @francislavoie --we're looking into it

gwprice115 commented 6 days ago

hey @francislavoie, this should now be fixed. thanks for reporting!