Coder Social home page Coder Social logo

Chrome : MLHttpRequest cannot load http://XX.XX.XX.XX:8545/. Response to preflight request doesn't pass access control check about anonymousvoting HOT 3 CLOSED

stonecoldpat avatar stonecoldpat commented on June 18, 2024
Chrome : MLHttpRequest cannot load http://XX.XX.XX.XX:8545/. Response to preflight request doesn't pass access control check

from anonymousvoting.

Comments (3)

stonecoldpat avatar stonecoldpat commented on June 18, 2024

Hey,

Let me understand the situation. The user is running the website on their machine (i.e. vote.html) and then trying to connect to an Ethereum node (i.e. Geth) on a distant machine? I'll ask around as I haven't tried this before, but is there any reason for this approach?

I'm not sure if Web3 can guarantee it is talking to a legit full Ethereum node (i.e. has a full copy of the blockchain). This is not normally a concern since a node is on the user's actual machine, but if it is in the distance then that implies a different trust model i.e. we are trusting remote machine to really be running an Ethereum node. If this is the trust model you have - why not just run have vote.html connect directly to the web server (some .php scripts) instead of the Ethereum node?

from anonymousvoting.

stonecoldpat avatar stonecoldpat commented on June 18, 2024

A friend told me the following:

You'll have to make sure your request passes the correct 'origin' property.
Either anonymous or with-credentials.

Then your remote server needs to have the correct CORS policy.
See your server docs to see how to set this.
(Example with GET requests:)
AllowedOrigin: *
AllowedMethod: GET
AllowedHeader: *

I hope the above is a good pointer on what to do next?

from anonymousvoting.

descampsk avatar descampsk commented on June 18, 2024

Thanks for your answer !

I didn't got the time yet to try your solution but I will keep you informed of the results.

For more informations, i'm trying to build a Docker image which can automatically connect to a private Blockchain with rpc allowed, to simplify the connection to the Blockchain for the user.

  1. The user launch the Docker image on his local machine and is connected to the Blockchain.
  2. Then he runs the website on his local machine, and the javascript code connects to the node with rpc.

The issue is that the Docker Engine create a virtual machine on Windows and a network between the host and this machine. The Ethereum node is on this machine, and the website need to go through this network to be connected to the node.

To summerize, the user is running the website on their machine (i.e. vote.html) and then trying to connect to an Ethereum node (i.e. Geth) on the "virtual" distant machine. All machines are locals but Chrome "think" the Ethereum node is on a distant machine and refuse the connection.

I don't know if I'm really clear, my English is not so good, and it's a bit complicated to explain ^^.

from anonymousvoting.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.