blazegraph / database

Blazegraph High Performance Graph Database
GNU General Public License v2.0
872 stars 170 forks source link

Setting CORS When Accessing the Blazegraph Database #227

Open Superraptor opened 2 years ago

Superraptor commented 2 years ago

I'm cross-posting an issue I've been having with a local install of the Wikidata Query RDF and the Wikidata Query GUI (https://phabricator.wikimedia.org/T308180), which pertains to the GUI being able to access the Blazegraph hosted at http://localhost:9999. I had attempted to follow a solution mentioned here from 2014, but it unfortunately did not work. I absolutely apologize if this is the wrong location to ask, but I'm at a bit of my wit's end, and I hope I'm missing something obvious which you may be able to help me with.

I am curious if there is a recommended option for setting CORS with Blazegraph. In addition to the solution above, I have tried editing the following into every instance of ./WEB-INF/web.xml in the wikidata-query-rdf directory, which also hasn't worked:

<filter>
   <filter-name>cross-origin</filter-name>
   <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
   <init-param>
       <param-name>allowedOrigins</param-name>
       <param-value>*</param-value>
   </init-param>
   <init-param>
       <param-name>allowedMethods</param-name>
       <param-value>GET,POST,OPTIONS,DELETE,PUT,HEAD</param-value>
   </init-param>
   <init-param>
       <param-name>allowedHeaders</param-name>
       <param-value>origin, content-type, accept, authorization</param-value>
   </init-param>
</filter>
<filter-mapping>
    <filter-name>cross-origin</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

Any help would be incredibly appreciated! Thank you for your time!

alhuber1502 commented 2 years ago

Not sure this helps, but I could never get this to work. In the end I used Apache's reverse-proxy mechanism to tunnel any queries. No need for open ports or nginx configuration, and Apache can handle everything CORS-related.

balhoff commented 2 years ago

@Superraptor I use CORS with Blazegraph. You can see the setup in my docker image here: https://github.com/phenoscape/blazegraph-docker/blob/master/Dockerfile

You need to add the jetty-servlets jar to the classpath.