Skip to content

Commit

Permalink
Send etag as query param (#91)
Browse files Browse the repository at this point in the history
* sendetagasqueryparam

* comments

* v9.2.0
laliconfigcat authored Dec 27, 2023
1 parent b25860b commit 662179e
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "configcat-js",
"version": "9.1.0",
"version": "9.2.0",
"description": "ConfigCat is a configuration as a service that lets you manage your features and configurations without actually deploying new code.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
8 changes: 7 additions & 1 deletion src/ConfigFetcher.ts
Original file line number Diff line number Diff line change
@@ -35,10 +35,16 @@ export class HttpConfigFetcher implements IConfigFetcher {
httpRequest.onabort = () => reject(new FetchError("abort"));
httpRequest.onerror = () => reject(new FetchError("failure"));

httpRequest.open("GET", options.getUrl(), true);
let url = options.getUrl();
if (lastEtag) {
// We are sending the etag as a query parameter so if the browser doesn't automatically adds the If-None-Match header, we can transorm this query param to the header in our CDN provider.
url += '&ccetag=' + lastEtag;
}
httpRequest.open("GET", url, true);
httpRequest.timeout = options.requestTimeoutMs;
// NOTE: It's intentional that we don't specify the If-None-Match header.
// The browser automatically handles it, adding it manually would cause an unnecessary CORS OPTIONS request.
// In case the browser doesn't handle it, we are transforming the ccetag query parameter to the If-None-Match header in our CDN provider.
httpRequest.send(null);
}
catch (err) {

0 comments on commit 662179e

Please sign in to comment.