From 8d038c5869dc3d98b4ff80680c38423d4a51fe39 Mon Sep 17 00:00:00 2001 From: gozzy Date: Sun, 20 Nov 2022 23:00:42 +0000 Subject: [PATCH] event rpc and graph cors policies --- services/events.js | 18 +++++++++++++++++- services/graph.js | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/services/events.js b/services/events.js index 4fc71fa..ff262c3 100644 --- a/services/events.js +++ b/services/events.js @@ -441,7 +441,23 @@ class EventsFactory { instances = new Map() constructor(rpcUrl) { - this.provider = new Web3(rpcUrl).eth + this.provider = new Web3( + new Web3.providers.HttpProvider(rpcUrl, { + headers: [ + { + name: 'Access-Control-Allow-Origin', + value: rpcUrl + }, + { + name: 'Access-Control-Allow-Methods', + value: 'POST, GET, OPTIONS' + } + ], + withCredentials: false, + // buffer for tor connections + timeout: 30000 + }) + ).eth } getBlockNumber = () => { diff --git a/services/graph.js b/services/graph.js index fb306df..d24a83e 100644 --- a/services/graph.js +++ b/services/graph.js @@ -39,6 +39,7 @@ const defaultOptions = { const client = new ApolloClient({ uri: link, + credentials: 'same-origin', cache: new InMemoryCache(), defaultOptions }) @@ -46,6 +47,7 @@ const client = new ApolloClient({ const registryClient = new ApolloClient({ uri: 'https://api.thegraph.com/subgraphs/name/tornadocash/tornado-relayer-registry', cache: new InMemoryCache(), + credentials: 'same-origin', defaultOptions })