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

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

Closed
dora1998 opened this issue Dec 27, 2020 · 3 comments · Fixed by #3028
Assignees

Comments

@dora1998
Copy link

[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.

@samtstern
Copy link
Contributor

@dora1998 thanks for reporting this! Seems like a clear bug in our new apiv2 code.

@bkendall
Copy link
Contributor

Sorry I'm so slow in coming to these. Let me take a look.

@bkendall
Copy link
Contributor

Well, that was pretty straight forward to fix. Assuming all goes well, watch for it in a new release of firebase-tools once this is closed.

This was referenced Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants