400 error: unknown_domain, can't connect to canister in IC network from local project

In the last week and before, I have never seen this error reported.
I’m connecting to the IC network through my local project (localhost:3000) and it generates the error: AgentHTTPResponseError: Server returned an error.
Code: 400 (Bad Request)
Body: unknown_domain
After testing on multiple computers, this does not appear to be a problem with my personal computer.
But I don’t know exactly what’s wrong, since I haven’t changed the code about the API recently.

What dfx version is this and did you update dfx recently?

dfx 0.17.0, no dfx updates.
We’ve tried rolling back the did multiple times, and this problem occurs after rolling it back

We recently renewed our domain name once, but the issue only occurs locally, the online environment is working fine

Does the issue disappear if you use 127.0.0.1 instead of localhost?

This problem does not occur, but it is not possible to call II, and the initialization of the authorization leads to a direct error:

index.ts:34 beforeEnter Err: Error: Global crypto was not available and none was provided. Please inlcude a SubtleCrypto implementation. See https:// developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto
    at _getEffectiveCrypto (chunk-CZQH26SK.js?v=35fbe591:2594:11)
    at _ECDSAKeyIdentity.generate (chunk-CZQH26SK.js?v=35fbe591:2616:29)
    at AuthClient.create (chunk-CZQH26SK.js?v=35fbe591:3455:38)
    at async initAuth (auth.ts:32:14)
    at async beforeEnter (index.ts:27:20)

Here are our dependency versions

    “@dfinity/agent”:“^0.19.3”,
    “@dfinity/auth-client“:”^0.19.3”,
    “@dfinity/candid“:”^0.19.3”,
    “@dfinity/identity“:”^0.19.3”,

You are on pretty old versions of the @dfinity/ dependencies and dfx is old-ish as well. Is there a chance that you could update? I’m pretty sure that would fix most of your issues

I’ve updated the dependency version to the latest, haven’t updated dfx yet, and it still shows the 400 unknown domain error.

    "@dfinity/agent": "^2.1.1",
    "@dfinity/principal": "^2.1.1",
    "@dfinity/auth-client": "^2.1.1",
    "@dfinity/candid": "^2.1.1",

I’ll try to update dfx next

1 Like

:+1: just don’t forget to dfx stop and dfx start after the upgrade, otherwise you won’t notice a difference from upgrading dfx

1 Like

No, I didn’t start dfx locally, I connected to the canister in the IC environment in my local front-end project

Hi, I updated the dfx and still find errors.
I need to emphasize that I’m using a local frontend project connected to a canister in the IC network.
Not a copy of the local dfx build used.
This setup was working until last week and I could test it locally online, but since yesterday it suddenly doesn’t work.

I’m out of ideas. @kpeacock do you maybe have an idea?

I tried a number of things including: testing with multiple computers, rolling back code, updating dependencies, and looking at recently modified code.
Now I have a breakthrough.
I just changed the canister id pointing to the backend to change the id to a different canister, but it still reports an error 400 unknown_domain.
I’m guessing there might be a problem with the step that initiates the api request.
And I’m wondering if there have been any recent updates to @dfinity/agent in this regard?

:cold_face: I’ve solved the problem, which was as follows: foundation’s api url was migrated and my local forwarding url wasn’t updated, causing the forwarding to fail


After changing the URL to the latest https://icp-api.io, the local project is running normally.

1 Like

I would like to know where I can subscribe to the Foundation’s api URL to prevent this from happening again.
:imp:This bug has been killing me for the past 2 days.

The domain change was triggered by this incident. We hope it won’t happen again, but if it would, the changes would be announced first here on the forum

1 Like