Skip to content

Commit 639abd2

Browse files
committed
add random query param in authentication endpoint to bypass safari caching on iOS
1 parent 067768e commit 639abd2

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/utils/request.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ export const generateSignatureToken = (
6565
return new Promise((resolve, reject) => {
6666
var xhr = new XMLHttpRequest();
6767
xhr.timeout = 60000;
68-
xhr.open('GET', authenticationEndpoint);
68+
var urlObj = new URL(authenticationEndpoint);
69+
urlObj.searchParams.set("t", new Date().getTime().toString());
70+
xhr.open('GET', urlObj.toString());
6971
xhr.ontimeout = function (e) {
7072
return reject(errorMessages.AUTH_ENDPOINT_TIMEOUT);
7173
};

test/upload.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const uploadSuccessResponseObj = {
2727
};
2828

2929
function successSignature() {
30-
server.respondWith("GET", initializationParams.authenticationEndpoint,
30+
server.respondWith("GET", new RegExp(initializationParams.authenticationEndpoint + ".*"),
3131
[
3232
200,
3333
{ "Content-Type": "application/json" },
@@ -41,7 +41,7 @@ function successSignature() {
4141
}
4242

4343
function nonSuccessErrorSignature() {
44-
server.respondWith("GET", initializationParams.authenticationEndpoint,
44+
server.respondWith("GET", new RegExp(initializationParams.authenticationEndpoint + ".*"),
4545
[
4646
403,
4747
{ "Content-Type": "application/json" },
@@ -221,7 +221,7 @@ describe("File upload", function () {
221221
expect(server.requests.length).to.be.equal(2);
222222

223223
// Simulate non 200 response on authentication endpoint
224-
server.respondWith("GET", initializationParams.authenticationEndpoint,
224+
server.respondWith("GET", new RegExp(initializationParams.authenticationEndpoint + ".*"),
225225
[
226226
200,
227227
{ "Content-Type": "application/json" },
@@ -245,7 +245,7 @@ describe("File upload", function () {
245245
expect(server.requests.length).to.be.equal(2);
246246

247247
// Simulate non 200 response on authentication endpoint
248-
server.respondWith("GET", initializationParams.authenticationEndpoint,
248+
server.respondWith("GET", new RegExp(initializationParams.authenticationEndpoint + ".*"),
249249
[
250250
200,
251251
{ "Content-Type": "application/json" },
@@ -664,7 +664,7 @@ describe("File upload", function () {
664664
});
665665

666666
expect(server.requests.length).to.be.equal(2);
667-
server.respondWith("GET", newAuthEndpoint,
667+
server.respondWith("GET", new RegExp(newAuthEndpoint + ".*"),
668668
[
669669
200,
670670
{ "Content-Type": "application/json" },

0 commit comments

Comments
 (0)