My Intent
Ahoy ICP devs!
Within the internal DFINITY team channels (OpenChat, Signal, Slack), I have seen some developer-centric technical questions which I think would be great for the wider developer forum to see. I think they can be helpful to share the question/answer so future folks looking for answers can find them.
This is my first attempt at doing this, and if people do not find it useful, I will stop
Let me know what you think. Thanks!
Question
How can I get a json file hosted on the IC with JS in the browser?
fetch
isn’t working because I get CORS issues. Can they be set in the canister? Or should I use agent-js somehow? I believe it’s a normal CORS issue, but with IC maybe I’m missing something
Thanks!
Answer
you can configure the asset canister to return custom headers, i.e., you can configure
*Access-Control-Allow-Origin: **
there and you should be able to fetch it from a different origin.