Skip to content

Commit 08b9cb9

Browse files
committed
Merge branch 'master' into auth-emulator-modify-secuirity
2 parents b2dbe33 + 331c955 commit 08b9cb9

File tree

7 files changed

+23
-91
lines changed

7 files changed

+23
-91
lines changed

.github/workflows/node-test.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,6 @@ jobs:
5555
- run: npm ci
5656
- run: npm test
5757

58-
- name: Coveralls (in parallel)
59-
uses: coverallsapp/github-action@master
60-
with:
61-
github-token: ${{ secrets.github_token }}
62-
flag-name: run-${{ matrix.node-version }}
63-
path-to-lcov: "./.coverage/lcov.info"
64-
parallel: true
65-
66-
finish-coverage:
67-
needs: unit
68-
runs-on: ubuntu-latest
69-
steps:
70-
- name: Coveralls finalization
71-
uses: coverallsapp/github-action@master
72-
with:
73-
github-token: ${{ secrets.github_token }}
74-
parallel-finished: true
75-
7658
integration:
7759
needs: unit
7860
if: github.event_name == 'push'

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
- Fixes issue where emulated HTTP functions would crash when the URL contained query parameters (#3032)
44
- Fixes issue with routing to emulated HTTP functions in regions outside of `us-central1` (#3031)
55
- Fixes issue where authorized domains were not being correctly updated when deploying to Hosting channels. (#3002)
6+
- Fixes issue where the User-Agent was being overridden when proxying through the Hosting emulator. (#2970)

package-lock.json

Lines changed: 0 additions & 71 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@
178178
"@typescript-eslint/parser": "^4.12.0",
179179
"chai": "^4.2.0",
180180
"chai-as-promised": "^7.1.1",
181-
"coveralls": "^3.1.0",
182181
"eslint": "^7.17.0",
183182
"eslint-config-google": "^0.14.0",
184183
"eslint-config-prettier": "^7.1.0",

src/apiv2.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,9 @@ export class Client {
229229
reqOptions.headers = new Headers();
230230
}
231231
reqOptions.headers.set("Connection", "keep-alive");
232-
reqOptions.headers.set("User-Agent", `FirebaseCLI/${CLI_VERSION}`);
232+
if (!reqOptions.headers.has("User-Agent")) {
233+
reqOptions.headers.set("User-Agent", `FirebaseCLI/${CLI_VERSION}`);
234+
}
233235
reqOptions.headers.set("X-Client-Version", `FirebaseCLI/${CLI_VERSION}`);
234236
if (reqOptions.responseType === "json") {
235237
reqOptions.headers.set("Content-Type", "application/json");

src/hosting/initMiddleware.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ export function initMiddleware(init: TemplateServerResponse): RequestHandler {
3434
if (sdkRes.status === 404) {
3535
return next();
3636
}
37+
for (const [key, value] of Object.entries(sdkRes.response.headers.raw())) {
38+
res.setHeader(key, value);
39+
}
3740
sdkRes.body.pipe(res);
3841
})
3942
.catch((e) => {

src/test/apiv2.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,22 @@ describe("apiv2", () => {
223223
expect(nock.isDone()).to.be.true;
224224
});
225225

226+
it("should make a basic GET request and not override the user-agent", async () => {
227+
nock("https://example.com")
228+
.get("/path/to/foo")
229+
.matchHeader("user-agent", "unit tests, silly")
230+
.reply(200, { success: true });
231+
232+
const c = new Client({ urlPrefix: "https://example.com" });
233+
const r = await c.request({
234+
method: "GET",
235+
path: "/path/to/foo",
236+
headers: { "user-agent": "unit tests, silly" },
237+
});
238+
expect(r.body).to.deep.equal({ success: true });
239+
expect(nock.isDone()).to.be.true;
240+
});
241+
226242
it("should handle a 204 response with no data", async () => {
227243
nock("https://example.com").get("/path/to/foo").reply(204);
228244

0 commit comments

Comments
 (0)