HTTP Proxy

On this page

    Optionally, you can configure a proxy to redirect all HTTP(S) traffic. This is for example useful when Comunica is used in a Web browser where a proxy enables CORS headers on all responses.

    Proxying on the command line

    Via the command line, a proxy can be enabled via the -p option as follows:

    $ comunica-sparql "SELECT * WHERE { ?s ?p ?o }" \

    Proxying in an application

    When using Comunica SPARQL in an application, a proxy can be set using the httpProxyHandler context entry:

    import { ProxyHandlerStatic } from "@comunica/actor-http-proxy";
    const bindingsStream = await myEngine.queryBindings('SELECT * WHERE { ?s ?p ?o }', {
      sources: [''],
      httpProxyHandler: new ProxyHandlerStatic(''),

    In the example above, a ProxyHandlerStatic is passed, which will simply put the URL in front of all URLs that would be requested.

    If you need a more advanced proxy behaviour, then you can implement your own proxy handler. All proxy handlers must implement the IProxyHandler interface.