Skip to content

Commit 2d944de

Browse files
authored
Merge pull request #3663 from AlchemyCMS/backport/8.0-stable/pr-3661
[8.0-stable] Include credentials in update check fetch request
2 parents d4bd361 + aeeb3dc commit 2d944de

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

app/javascript/alchemy_admin/components/update_check.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class UpdateCheck extends HTMLElement {
66
spinner.spin(this)
77

88
try {
9-
const response = await fetch(this.url)
9+
const response = await fetch(this.url, { credentials: "include" })
1010
const responseJSON = await response.json()
1111

1212
if (response.ok) {

spec/javascript/alchemy_admin/components/update_check.spec.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ describe("alchemy-update-check", () => {
2727
vi.clearAllMocks()
2828
})
2929

30+
it("fetches with credentials included", async () => {
31+
global.fetch.mockResolvedValueOnce({
32+
ok: true,
33+
json: () => Promise.resolve({ status: "true" })
34+
})
35+
36+
component = renderComponent("alchemy-update-check", html)
37+
await new Promise(process.nextTick)
38+
39+
expect(global.fetch).toHaveBeenCalledWith("/update_check", {
40+
credentials: "include"
41+
})
42+
})
43+
3044
it("shows update available when response is 'true'", async () => {
3145
global.fetch.mockResolvedValueOnce({
3246
ok: true,

0 commit comments

Comments
 (0)