Skip to content

Commit 654984d

Browse files
committed
Allow the setting of cookies when loading projects
This is to allow us to drop a cookie that can be used to authorize requests made by Scratch. Using withCredentials allows cookies to be set in the request response.
1 parent e65fe3b commit 654984d

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/utils/apiCallHandler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const ApiCallHandler = ({ reactAppApiEndpoint }) => {
6565
const queryString = locale ? `?locale=${locale}` : "";
6666
return await get(
6767
`${host}/api/projects/${projectIdentifier}${queryString}`,
68-
{ headers: headers(accessToken) },
68+
{ headers: headers(accessToken), withCredentials: true },
6969
);
7070
};
7171

src/utils/apiCallHandler.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ describe("Testing project API calls", () => {
105105
await readProject(projectIdentifier);
106106
expect(axios.get).toHaveBeenCalledWith(
107107
`${host}/api/projects/${projectIdentifier}`,
108-
defaultHeaders,
108+
{ ...defaultHeaders, withCredentials: true },
109109
);
110110
});
111111

@@ -117,7 +117,7 @@ describe("Testing project API calls", () => {
117117
await readProject(projectIdentifier, locale);
118118
expect(axios.get).toHaveBeenCalledWith(
119119
`${host}/api/projects/${projectIdentifier}?locale=${locale}`,
120-
defaultHeaders,
120+
{ ...defaultHeaders, withCredentials: true },
121121
);
122122
});
123123

@@ -128,7 +128,7 @@ describe("Testing project API calls", () => {
128128
await readProject(projectIdentifier, null, accessToken);
129129
expect(axios.get).toHaveBeenCalledWith(
130130
`${host}/api/projects/${projectIdentifier}`,
131-
authHeaders,
131+
{ ...authHeaders, withCredentials: true },
132132
);
133133
});
134134

0 commit comments

Comments
 (0)