Is it possible to make raw.ic0.app calls from ic0.app and reverse?

I want to make a request from my application to another application via an unsafe API (ic0.raw.app), but I get an error. Is this the target behavior?

It seems that the Service worker did not resolve a canister ID from another domain URL.
Steps to reproduce:

  • Go to https://***.ic0.app
  • make fetch('https://***.raw.ic0.app/index.html')
  • Got error URL "https://***.raw.ic0.app/" did not resolve to a canister ID.

After debugging I found, that service worker unable to resolve canisterId when page hostname does not match requesting URL. Difference is between *.ic0.app and *.raw.ic0.app.

It’s blocker for me because I want to check certificated assets from raw resource before the load a resource in IFrame. And this is the last way to solve my problem after Why can’t IFrame be used with certificated URLs?

Please, help or answer

1 Like

Also, there is no way to register custom service worker on https://***.ic0.app, because any request to main domain is accompanied by bootstrap-page loading instead of a custom worker JS-source.

Will us be able to register out custom service workers in future?

I’m surprised: When accessing *.raw.ic0.app, no service worker should be involved. The point of raw is that it hits the HTTP Gateway on the boundary node and no certificate checking happen, so no reason to have a service worker involved.

1 Like

This applies to requests from the frontend, where the service worker is already installed. For example

  • go to any canister (for example go to OpenChat https://7e6iv-biaaa-aaaaf-aaada-cai.ic0.app/)
  • open the console
  • we make a request to the same canister in raw domain zone fetch('https://7e6iv-biaaa-aaaaf-aaada-cai.raw.ic0.app')
  • got error, Network tab is empty

Good analysis. That sounds like a bug in the service worker to me – it should let raw urls through.

2 Likes

Roger! :slight_smile:
Any suggestions who can help with this issue?

It should be sufficient to extend this check, to let requests to raw urls through (just like requests to unrelated domains):

1 Like

And I still could not find the sourcecode (sorry). Thank you so much for the link!
Perhaps I’ll open a pull request :slight_smile:

1 Like

@kpeacock Check plz
Pull request

3 Likes

Pull request was merged.
@bitdivine @kpeacock Thanks you so much! :heart:

We appreciate the initiative, and thanks for bearing with us while we’re in the middle of migrating the serviceworker to a new codebase!

5 Likes