Skip to content

graphiql index.html - XSRF Header syntax error #1434

@nmck257

Description

@nmck257

Hi -- I'm no expert, but I believe this section:

const xsrfToken = document.cookie.match(new RegExp('(?:^| )XSRF-TOKEN=([^;]+)'));
const initialHeaders = xsrfToken ? `{ 'X-XSRF-TOKEN' : '${ xsrfToken[1] }' }` : undefined;

...has a typo. The headers are being written as JSON, but it's using single-quotes for the key and value, whereas JSON would want double-quotes.

On my machine, in Chrome, I'm booting an app on localhost and I happened to have an XSRF Cookie set. The "headers" section loads with single-quoted JSON (which graphiql syntax-highlights as an error), and the result pane loads with this content:

{
  "errors": [
    {
      "message": "Introspection failed. Request headers are invalid JSON: InvalidSymbol, PropertyNameExpected, InvalidSymbol, and ValueExpected."
    }
  ]
}

Meanwhile, the schema info in the left sidebars doesn't load.
I think it all traces back to graphiql failing to query the backend on page-load due to the JSON typo.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions