So I want to put a website on ipfs, but it has some javascript which calls out to a server that is not the ipfs gateway, so I get cross origin errors. Any idea how to do this?
You can set the Access-Control-Allow-Origin
header and other headers using ipfs config
:
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["GET", "POST"]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Headers '["Authorization"]'
ipfs config --json API.HTTPHeaders.Access-Control-Expose-Headers '["Location"]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials '["true"]'
The values above are just examples; set the real values to what your client code actually needs.
https://docs.ipfs.io/reference/api/cli/#ipfs-daemon has the (minimal) existing docs on this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With