Skip to content

Client side proxy

sea edited this page May 17, 2023 · 1 revision

To route your requests through a client side proxy, you can set a "ProxyConfiguration" at your SessionContext by providing the proxy server´s hostname and port.

// The SessionContext allows to set advanced options via setters.
let sessionContext: SessionContext = new SessionContext(WebServiceProtocol.REST, new URL("http://localhost:8080/webPDF/"));
sessionContext.setProxy({
   // Select the proxy server via hostname and port
   host: "127.0.0.1",
   port: 8888
} as AxiosProxyConfig);

// Next create the Session via the "SessionFactory".
// Also be aware: If no "AuthProvider" is selected in the "createInstance" Method, this will default to
// the "AnonymousAuthProvider".
try {
   // Do something.
   let session: RestSession<RestDocument> = await SessionFactory.createInstance(sessionContext);
} catch (error) {
   // Handle exceptions as you see fit.
}

Clone this wiki locally