Any reason why I can’t http_request between two canister, an asset canister and a server.mo canister on my localhost. I have tweaked the ic-asset.json5 without success. Strangely, I am able to call external cdn from the server canister when I add them to the ic-asset file.
Also, I had a look at the html source of the mycanister page (Internet Computer Loading) and it seems that the CSP open many address. This tag doesn’t appear for my canisters on both local and on ICP
Do I get it right, you cannot call a canister from your frontend app served in the browser right?
If correct, got few question:
It’s happening locally or on mainnet?
If locally, how do you serve your app (npm run … or dfx start)?
Your backend runs on the same domain / network?
The call that leads to the error is using agent-js?
Assuming it’s happening in a browser, can you maybe a screenshot of your browsers tab displaying the error?
This error on mainnet raw makes sense to me. The CSP does not accept the target domain in the connect-src rule. Add the targeted canister id to the rule and it should do.
In addition, don’t know how the certificed asset canister of dfx works but, I can imagine that even locally a Content Security Header is defined so might good be that even locally the targeted canister is not white listed.
When you have the CORS error in your browser, did you check what’s the actually rule and if it matches the canister you are targeting?
Ok! Thank you very much I’m getting in this right now. I’ll have to get a better knowledge on CSP.
Also, I imagine you noticed how long it took for the page to load…
The first part of the page load in about 2-3 seconds, I’m ok with this. But the call to my contact actor canister to get the contact list take very long. I thought that a query func would take not more than 4 secondes, am I right on this ? This is the link for my actual frontend (its the backend who response) until : https://rnftg-fiaaa-aaaam-abxja-cai.raw.icp0.io/
I have added the backend address to the “Content-Security-Policy” tag. I have tried different approach without success. Is there a tag in the ic-assets.json to allow a new type of request ?
Thank you
I’m not sure what your canister does so, I cannot really tell if surprising or not unfortunatelly. I would maybe try to solve the 404 before trying the solve the CSP issue, kind of feel that both are related. Locally everything works fine?
Yes, both are on localhost. . Using this method (https://rnftg-fiaaa-aaaam-abxja-cai.raw.icp0.io/) works fine. I was trying to resolve the 10-15 seconds delay between the canisters call, thought it would be related. Thank you for your help, I’ll try to resolve the 404 and report back if I find something.