Get certified domains icp0.io and icp-api.io

Assuming icp0.io and icp-api.io might change someday, is there a certified way to get these two domains from a canister?

Perhaps through a certified call or something similar to how I would obtain a canister’s ID using ic_cdk::id()?

2 Likes

Having a canister hold information about an HTTP Gateway, such as the TLDs it owns, could be interesting. What use case would you like to fulfill now with that information?

1 Like

I’m adding support for the II alternative frontend origins in Juno.

Given the use case, I’m not going to ask developers to configure a list of origins. Instead, I’ll ask them what custom domain should be used as the main domain to derive origins.

When they set one, the satellite will automatically generate and certify the /.well-known/ii-alternative-origins, including the default canister ID-based URLs.

fn set_alternative_origins(main_domain: &DomainName) -> Result<(), String> {
    let mut custom_domains: Vec<DomainName> = get_custom_domains_store()
        .keys()
        .filter(|domain| *domain != main_domain)
        .cloned()
        .collect();

    // Add default system URL to alternative origin as well
    custom_domains.push(format!("{}.icp0.io", id().to_text()));

    ...

This is why I end up having to hardcode the icp0.io domain.

That said, writing down these lines makes me realize that maybe the II spec should be extended to include canister IDs without domain names.

3 Likes