Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPFS - yet another CORS issue #181

marsrobertson opened this issue Apr 25, 2019 · 0 comments


None yet
1 participant
Copy link

commented Apr 25, 2019

Failed to load resource: the server responded with a status of 400 (Bad Request)
upload-infura.html:1 Access to fetch at '' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Here is my super simple demo

<!DOCTYPE html>
    <meta charset="UTF-8">
    <title>Infura IPFS CORS issue</title>

    <script src=""></script>
    <script src=""></script>
    <script src=""></script>


  	<h3>readAsArrayBuffer to Buffer to Infura to IPFS</h3>
  	<input type="file" id="upload">

  		const ipfs = window.IpfsHttpClient('', '5001')

  		$("#upload").on("change", function() {
	        var reader = new FileReader();
	        reader.onload = function (e) {

	        	const magic_array_buffer_converted_to_buffer = buffer.Buffer(reader.result); // honestly as a web developer I do not fully appreciate the difference between buffer and arrayBuffer 
				ipfs.add(magic_array_buffer_converted_to_buffer, (err, ipfsHash) => {

Related links:

I'm not that good at coding, that's why my code must be simple.


Adding { protocol: "https" } seems to be solving the issue.

const ipfs = window.IpfsHttpClient('', '5001')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.