diff --git a/Changelog.md b/Changelog.md index f63149a98..2cae446bb 100644 --- a/Changelog.md +++ b/Changelog.md @@ -45,6 +45,9 @@ a more pleasant experience, especially for users with larger databases. - **Fixed** some SPARQL endpoints by using `application/sparql-results+json` accept header for SPARQL requests ([#499](https://github.com/aws/graph-explorer/pull/499)) +- **Fixed** CORS issue for some SPARQL and Gremlin endpoints due to `queryId` in + the request headers ([#529](https://github.com/aws/graph-explorer/pull/529)) + ([#499](https://github.com/aws/graph-explorer/pull/499)) - **Fixed** text wrapping for labels in edge styling sidebar ([#499](https://github.com/aws/graph-explorer/pull/499)) - **Fixed** potential error when the request body is very large by increasing diff --git a/packages/graph-explorer/src/connector/gremlin/gremlinExplorer.ts b/packages/graph-explorer/src/connector/gremlin/gremlinExplorer.ts index 2db7d6d81..6af4ad3d5 100644 --- a/packages/graph-explorer/src/connector/gremlin/gremlinExplorer.ts +++ b/packages/graph-explorer/src/connector/gremlin/gremlinExplorer.ts @@ -18,7 +18,7 @@ function _gremlinFetch(connection: ConnectionConfig, options: any) { "Content-Type": "application/json", Accept: "application/vnd.gremlin-v3.0+json", }; - if (options?.queryId && connection?.proxyConnection === true) { + if (options?.queryId && connection.proxyConnection === true) { headers.queryId = options.queryId; } diff --git a/packages/graph-explorer/src/connector/sparql/sparqlExplorer.ts b/packages/graph-explorer/src/connector/sparql/sparqlExplorer.ts index b0d896d0d..7b23eb3ff 100644 --- a/packages/graph-explorer/src/connector/sparql/sparqlExplorer.ts +++ b/packages/graph-explorer/src/connector/sparql/sparqlExplorer.ts @@ -136,16 +136,17 @@ function _sparqlFetch(connection: ConnectionConfig, options?: any) { return async (queryTemplate: string) => { logger.debug(queryTemplate); const body = `query=${encodeURIComponent(queryTemplate)}`; - const headers = options?.queryId - ? { - accept: "application/sparql-results+json", - "Content-Type": "application/x-www-form-urlencoded", - queryId: options.queryId, - } - : { - accept: "application/sparql-results+json", - "Content-Type": "application/x-www-form-urlencoded", - }; + const headers = + options?.queryId && connection.proxyConnection === true + ? { + accept: "application/sparql-results+json", + "Content-Type": "application/x-www-form-urlencoded", + queryId: options.queryId, + } + : { + accept: "application/sparql-results+json", + "Content-Type": "application/x-www-form-urlencoded", + }; return fetchDatabaseRequest(connection, `${connection.url}/sparql`, { method: "POST", headers,