ngrep to localhost:5001 should show any traffic sent to the IPFS API from the cluster proxy endpoint.
You are using cluster 0.8.0 or above right?? We definitely hardcode more headers than the ones your response is showing.
I just tested and it works for me:
[20:04:41] ~ $ curl -v -X POST 'localhost:9095/api/v0/add' -F file=@ipfs-test.txt -H 'Origin: localhost:9095'
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying ::1...
* TCP_NODELAY set
* connect to ::1 port 9095 failed: Connection refused
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 9095 (#0)
> POST /api/v0/add HTTP/1.1
> Host: localhost:9095
> User-Agent: curl/7.60.0
> Accept: */*
> Origin: localhost:9095
> Content-Length: 207
> Content-Type: multipart/form-data; boundary=------------------------8fff3c7783835b37
>
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length
< Cache-Control: no-cache
< Connection: close
< Content-Type: application/json
< Server: ipfs-cluster/ipfsproxy/0.9.0+git041f5e1e937d1b4376f12825f25a823bc58d5767
< Trailer: X-Stream-Error
< Vary: Origin
< Vary: Access-Control-Request-Method
< Vary: Access-Control-Request-Headers
< X-Chunked-Output: 1
< Date: Thu, 28 Feb 2019 20:04:46 GMT
< Transfer-Encoding: chunked
<
You need to make sure that the IPFS config for CORS is correct. It needs to be in the API
section, not the HTTPGateway
one. And it needs to allow POST
:
"API": {
"HTTPHeaders": {
"Access-Control-Allow-Headers": [
"X-Requested-With",
"Range"
],
"Access-Control-Allow-Methods": [
"POST", "GET"
],
"Access-Control-Allow-Origin": [
"*"
]
}
},