while interfacing my node.js project with smart contract and deploy it, i am getting this error.
i have also attached screenshots of error
[Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
Failed to load http://localhost:8545/: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://localhost:3000' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
Uncaught Error: CONNECTION ERROR: Couldn't connect to node http://localhost:8545.
at Object.InvalidConnection (web3.min.js:1)
at t.send (web3.min.js:1)
at n.send (web3.min.js:1)
at l.accounts (web3.min.js:1)
at sol:45
you must add param: --rpccorsdomain "http://localhost:3000" when you run your local node.
I was able to fix this error, the version of web3 must be downgraded, navigate to the folder you want to save in, run npm init then the following code
Use this command to install: npm install [email protected] --save within the same folder and this worked fine for me
@loydbanks I was also facing the same issue and I tried with your solution but get this 2 below error now. Please help me out to resolve.
Failed to load resource: net::ERR_CONNECTION_REFUSED
i.send @ web3.min.js:1
web3.min.js:1 Uncaught Error: CONNECTION ERROR: Couldn't connect to node http://localhost:8545.
at Object.InvalidConnection (web3.min.js:1)
at i.send (web3.min.js:1)
at s.send (web3.min.js:1)
at _.accounts (web3.min.js:1)
at index.html:41
@loydbanks solved. forgot to run testrpc.
@SUBHRA7 could you please provide the entire command? i've actually opened a PR that sets required credentials to false when no credentials are supplied for use in testing, with that it's a matter of running
geth --dev --rpc --rpccorsdomain="*" --rpcaddr="localhost"
and then using the default web3 connection
EDIT: @loydbanks the PR's change allows access without downgrading
I don't know anything about the last email you sent me but i was able to
make this work by using another version of web3, i used the following
command.
This command must be done within the folder you have ran npm init. The
command is npm install [email protected] and i was able to connect
On Tue, 25 Sep 2018 at 23:02, SUBHRA7 notifications@github.com wrote:
@loydbanks https://github.com/loydbanks I was also facing the same
issue and I tried with your solution but get this 2 below error now. Please
help me out to resolve.
Failed to load resource: net::ERR_CONNECTION_REFUSED
i.send @ web3.min.js:1
web3.min.js:1 Uncaught Error: CONNECTION ERROR: Couldn't connect to node
http://localhost:8545.
at Object.InvalidConnection (web3.min.js:1)
at i.send (web3.min.js:1)
at s.send (web3.min.js:1)
at _.accounts (web3.min.js:1)
at index.html:41—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/ethereum/web3.js/issues/1826#issuecomment-424595069,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AkJZfcEJ3K1FhYvoCNNXZVqxYZCjjwKnks5uexh3gaJpZM4Vq7vn
.
@loydbanks the emails are github notifications, so i'm not sure i understand what you're referring to. if you look at the PR i linked to previously you'll be able to make the latest version of web3 work with localhost (and be able to build it properly); you can see the changes i've made here until the PR is approved (assuming it ever will be)
@therightstuff no wories I‘ll have a look on your PR next week
write in php
header("Access-Control-Allow-Origin: http://localhost:8545");
Most helpful comment
I was able to fix this error, the version of web3 must be downgraded, navigate to the folder you want to save in, run npm init then the following code
Use this command to install: npm install [email protected] --save within the same folder and this worked fine for me