ipfs / js-kubo-rpc-client

A client library for the Kubo RPC API
https://www.npmjs.com/package/kubo-rpc-client
Other
35 stars 7 forks source link

CORS Error #214

Closed prohtmlcoder closed 9 months ago

prohtmlcoder commented 9 months ago

Hi There, newbie here, trying to learn Web3 Stack.

Problem:

I am using the node version of this package.

IPFS Version:ipfs version 0.20.0

I am starting the node in the offline mode using:

ipfs daemon -- offline

I am using Svelte in Routify boiler plate. 
Here is my code:

<script>
    import { create } from 'kubo-rpc-client'

let ipfs = 95;
async function check()
{
    ipfs = create({  host: 'localhost',  port: 5001,
    protocol: 'http',  headers: {    authorization: 'Basic ' + btoa('alice:password123')  }})
    for await (const chunk of ipfs.cat("QmfZpxN6pcNZar7zKU5DAhokXfE7bF2Ej89db5ZMEvxZwf"))// This file is existing in the IPFS
    {    console.info(chunk)    }

}
</script>
<button on:click={check}>Check</button>
{ipfs}

I am getting the following errors:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:5001/api/v0/cat?arg=QmfZpxN6pcNZar7zKU5DAhokXfE7bF2Ej89db5ZMEvxZwf. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:5001/api/v0/cat?arg=QmfZpxN6pcNZar7zKU5DAhokXfE7bF2Ej89db5ZMEvxZwf. (Reason: CORS request did not succeed). Status code: (null).

Uncaught (in promise) TypeError: NetworkError when attempting to fetch resource. 

What am I doing wrong, how can I improve. Please help, I am stuck on this for a very long time

Here is my config file: con.json

Thank you in advance.

lidel commented 9 months ago

Hi @prohtmlcoder, we use github only for bugs and feature requests. In the future, please fill support questions like this at community forums at https://discuss.ipfs.tech/c/help/13

To get you started: