So... none of the writable public IPFS gateways are setting their CORS headers....

in ipfs •  7 years ago  (edited)
This is preventing the webapp I'm trying to create from being able to read back the ipfs-hash header whenever a file is posted.

The only work around that I can think of is to require that the webapp be run directly out of the IPFS filesystem of the public writable IPFS gateway that is being used to post the files.

For development looks like I'm going to have to add a localhost proxy....

What a pain in the ass!

It would be better to be able to randomly select from a list of writable gateways instead of the way things are starting to become painful...

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Yay!

I can now read the ipfs-hash header!

Simple servlet proxy added to project:


package proxy;

import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;

import org.mitre.dsmiley.httpproxy.ProxyServlet;

@WebServlet(initParams = { //
@WebInitParam(name = "targetUri", value = "https://GATEWAY/ipfs"), //
@WebInitParam(name = ProxyServlet.P_LOG, value = "true"), //
@WebInitParam(name = ProxyServlet.P_HANDLEREDIRECTS, value = "true"),
@WebInitParam(name = ProxyServlet.P_PRESERVECOOKIES, value="true"),
@WebInitParam(name = ProxyServlet.P_PRESERVEHOST, value="false")//
}, loadOnStartup = 1, urlPatterns = "/ipfs/*")
@SuppressWarnings("serial")
public class Proxy extends ProxyServlet {
}

super article about IPFS

Thanks!

Hopefully I can work around the CORS issue well enough to provide a basic GWT/IPFS photos poster that will make posting simple photogalleries to steemit much simpler that what it is right now.

I was chasing my tail earlier thinking my interface to XHR object was somehow broken in GWT Elemental2 because I couldn't read the "ipfs-hash" response header even though I can see it in the debugging console. But the reason the GWT app can't read the header is because the CORS allowed headers header isn't being set on the result response on successful post causing any non-standard headers to be unreadable in the browser because of CORS restrictions.