Skip to content

functions cannot get user's User-Agent when you call it from hosting emulator by using rewrites #2970

@dora1998

Description

@dora1998

[REQUIRED] Environment info

firebase-tools: 9.1.0

Platform: macOS

[REQUIRED] Test case

  1. Create a project that uses hosting and functions.
  2. Call a function from hosting by rewrites.
  3. When you test on local emulator, the function cannot get user's User-Agent.

The reproducible sample is below.
https://github.com/dora1998/firebase-tools-ua-example

[REQUIRED] Steps to reproduce

  1. git clone https://github.com/dora1998/firebase-tools-ua-example.git
  2. yarn install && yarn serve --project YOUR_PROJECT_ID
  3. Access to http://localhost:5001/YOUR_PROJECT_ID/us-central1/checkUA, then you'll see your user agent.
  4. However, when you access to http://localhost:5000/foobar, you'll see FirebaseCLI/9.1.0 regardless of your User-Agent.

I think this line set the User-Agent regardless of user's one.
https://github.com/firebase/firebase-tools/blob/master/src/apiv2.ts#L203

[REQUIRED] Expected behavior

Functions can get user's UA.

[REQUIRED] Actual behavior

Functions always get FirebaseCLI/9.1.0 as User-Agent on local emulator.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions