{"record":{"id":"668459a80bb1459f","repo":"gatsbyjs/gatsby","slug":"graphql-request-was-redirected-to-responsepath","errorCode":null,"errorMessage":"GraphQL request was redirected to ${responsePath}","messagePattern":"GraphQL request was redirected to (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby-source-wordpress/src/utils/fetch-graphql.ts","lineNumber":780,"sourceCode":"            }\n          }),\n      { retries: 5 }\n    )\n\n    if (response.data === ``) {\n      throw new Error(`GraphQL request returned an empty string.`)\n    }\n\n    const { path }: { path: string } = urlUtil.parse(url)\n\n    const responsePath = response.request.path\n\n    if (\n      path !== responsePath &&\n      responsePath !== undefined &&\n      responsePath !== url\n    ) {\n      throw new Error(`GraphQL request was redirected to ${responsePath}`)\n    }\n\n    const contentType: string = response.headers[`content-type`]\n\n    if (!contentType.includes(`application/json;`)) {\n      throw new Error(`Unable to connect to WPGraphQL.`)\n    }\n  } catch (e) {\n    if (throwFetchErrors) {\n      throw e\n    }\n\n    await handleFetchErrors({\n      e,\n      reporter,\n      url,\n      timeout,\n      variables,","sourceCodeStart":762,"sourceCodeEnd":798,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby-source-wordpress/src/utils/fetch-graphql.ts#L762-L798","documentation":"fetch-graphql compares the request path it sent against the path on the response object. If they differ (and the response path is neither undefined nor the full url), the request was redirected — typically because the WordPress site forces a trailing slash, redirects http to https, or rewrites the GraphQL path. Redirects break introspection and schema retrieval, so the plugin refuses to proceed.","triggerScenarios":"WordPress configured to redirect /graphql to /graphql/ (or vice versa); http→https redirect not accounted for in pluginOptions.url; WPML or another multilingual plugin redirecting the endpoint; a permalink restructure that moved the GraphQL endpoint.","commonSituations":"Site migrated from http to https but pluginOptions.url still uses http; permalink/URL structure changed; trailing-slash enforcement plugin active; CDN/proxy rewriting the path.","solutions":["Update pluginOptions.url to match the canonical endpoint exactly (correct protocol, host, and trailing slash).","Disable or adjust any trailing-slash redirect for the GraphQL endpoint.","Hit the URL in a browser and follow the redirect chain to find the canonical form, then use that in pluginOptions.","Ensure WPGraphQL is served from a single stable path (no WPML domain switching)."],"exampleFix":"// before\nurl: `http://wp.example.com/graphql`\n\n// after\nurl: `https://wp.example.com/graphql/`","handlingStrategy":"validation","validationCode":"const canonical = await fetch(url, { method: 'POST', redirect: 'manual' })\nif (canonical.status >= 300 && canonical.status < 400) { throw new Error(`GraphQL url redirects to ${canonical.headers.get('location')}; update pluginOptions.url`) }","typeGuard":"null","tryCatchPattern":"try { await fetchGraphQL(opts) } catch (e) { if (/redirected to/.test(e.message)) { reporter.panic(`Fix pluginOptions.url: ${e.message}`) } throw e }","preventionTips":["Use the canonical endpoint URL (correct protocol, host, trailing slash) in pluginOptions","Disable trailing-slash redirects on the GraphQL path","Resolve all redirects once and pin the final URL"],"tags":["wordpress","graphql","redirect","config"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}