I used nginx reverse proxy to deal with cross-domain problems, but web3.js request https://xxx.xxx/5b44529e903c4ebf9d60e4d01c965489 throw "Uncaught Error: Can't autodetect provider for "xxx.xxx/5b44529e903c4ebf9d60e4d01c965489""
The cross-domain configuration of nginx is as follows
import data from './abi'
import Web3 from 'web3';
export default {
install: function (Vue, options) {
var web3 = window.web3;
var contract = '';
//web3 = new Web3("https://mainnet.infura.io /v3/5b44529e903c4ebf9d60e4d01c965489");
web3 = new Web3("www.xxx.xxx/5b44529e903c4ebf9d60e4d01c965489");
contract = new web3.eth.Contract(data.abi, data.address);
Vue.prototype.infuraContract = contract;
Vue.prototype.infuraWeb3 = web3;
//Web3 version "web3": "^1.0.0-beta.36";
}
}
I used nginx reverse proxy to deal with cross-domain problems, but web3.js request https://xxx.xxx/5b44529e903c4ebf9d60e4d01c965489 throw "Uncaught Error: Can't autodetect provider for "xxx.xxx/5b44529e903c4ebf9d60e4d01c965489""
The cross-domain configuration of nginx is as follows
web3.js code