Skip to content

Commit 547d650

Browse files
committed
Added fix to handle Cloudflare’s protection layer while making Rest Requests
1 parent 4ccc6fc commit 547d650

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/API/REST/constants/RESTConstants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,10 @@ export default class RESTConstants {
33
static readonly ACCEPT = 'Accept';
44
static readonly CONTENT_JSON = "application/json";
55
static readonly STATUS_CODE = "Status Code";
6+
static readonly USER_AGENT = "User-Agent";
7+
static readonly BROWSER_HEADER ="Mozilla/5.0 (Windows NT 10.0; Win64; x64)";
8+
static readonly ACCEPT_LANGUAGE = "Accept-Language";
9+
static readonly EN_US = "en-US,en;q=0.9";
10+
static readonly CONNECTION = "Connection";
11+
static readonly KEEP_ALIVE = "keep-alive";
612
}

src/API/REST/steps/UserSteps.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ export default class UserSteps {
1212
}
1313
private get header() {
1414
return this.api.header.set(RESTConstants.CONTENT_TYPE, RESTConstants.CONTENT_JSON)
15+
.set(RESTConstants.USER_AGENT, RESTConstants.BROWSER_HEADER)
16+
.set(RESTConstants.ACCEPT_LANGUAGE, RESTConstants.EN_US)
17+
.set(RESTConstants.CONNECTION, RESTConstants.KEEP_ALIVE)
1518
.set(RESTConstants.ACCEPT, RESTConstants.CONTENT_JSON).get();
1619
}
1720

0 commit comments

Comments
 (0)