We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 633118e commit 5662a55Copy full SHA for 5662a55
site/src/api/api.ts
@@ -16,8 +16,13 @@ export const hardCodedCSRFCookie = (): string => {
16
return csrfToken
17
}
18
19
-// Always attach CSRF token to all requests
20
-const token = document.head.querySelector('meta[property="csrf-token"]')
+// Always attach CSRF token to all requests.
+// In puppeteer the document is undefined. In those cases, just
21
+// do nothing.
22
+const token = typeof document !== 'undefined' ?
23
+ document.head.querySelector('meta[property="csrf-token"]') :
24
+ null
25
+
26
if (token !== null && token.getAttribute("content") !== null) {
27
if (process.env.NODE_ENV === "development") {
28
// Development mode uses a hard-coded CSRF token
0 commit comments