# Btcflower.xyz seems to be hosted on IC, but why this domain name does not need redirection

**URL:** <https://forum.dfinity.org/t/btcflower-xyz-seems-to-be-hosted-on-ic-but-why-this-domain-name-does-not-need-redirection/10787>\
**Category:** Jobs\
**Created:** [February 9, 2022, 6:39pm UTC](https://forum.dfinity.org/t/btcflower-xyz-seems-to-be-hosted-on-ic-but-why-this-domain-name-does-not-need-redirection/10787 "2022-02-09T18:39:20Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ysyms](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/ysyms/32/5173_2.png) [@ysyms](https://forum.dfinity.org/u/ysyms)\
**Post date:** [February 9, 2022, 6:39pm UTC](https://forum.dfinity.org/t/btcflower-xyz-seems-to-be-hosted-on-ic-but-why-this-domain-name-does-not-need-redirection/10787/1 "2022-02-09T18:39:20Z")

</div>

![image](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/e/e92aa77de264bd87d0822eb04251db8cf7e5daab.png)  
 ![image](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/b/b30e46b639af8b0ecb948ae71c9e3e7eed024325.jpeg)

---

<div class="post-metadata">

**Author:** ![paulyoung](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/paulyoung/32/5251_2.png) [@paulyoung](https://forum.dfinity.org/u/paulyoung)\
**Post date:** [February 9, 2022, 10:39pm UTC](https://forum.dfinity.org/t/btcflower-xyz-seems-to-be-hosted-on-ic-but-why-this-domain-name-does-not-need-redirection/10787/2 "2022-02-09T22:39:12Z")

</div>

@cryptoschindler maybe Moritz can explain 🙂

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [February 9, 2022, 11:12pm UTC](https://forum.dfinity.org/t/btcflower-xyz-seems-to-be-hosted-on-ic-but-why-this-domain-name-does-not-need-redirection/10787/3 "2022-02-09T23:12:13Z")

</div>

I think you do this using the ICXProxy. [https://github.com/dfinity/icx-proxy](https://github.com/dfinity/icx-proxy). How do you use it? Someone with more networking chops will have to explain.

---

<div class="post-metadata">

**Author:** ![gohan](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/gohan/32/4626_2.png) [@gohan](https://forum.dfinity.org/u/gohan)\
**Post date:** [February 10, 2022, 7:41am UTC](https://forum.dfinity.org/t/btcflower-xyz-seems-to-be-hosted-on-ic-but-why-this-domain-name-does-not-need-redirection/10787/4 "2022-02-10T07:41:24Z")

</div>

An entry over [smartcontracts.org](https://smartcontracts.org/) would be good

---

<div class="post-metadata">

**Author:** ![cryptoschindler](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/cryptoschindler/32/26_2.png) [@cryptoschindler](https://forum.dfinity.org/u/cryptoschindler)\
**Post date:** [February 10, 2022, 10:05am UTC](https://forum.dfinity.org/t/btcflower-xyz-seems-to-be-hosted-on-ic-but-why-this-domain-name-does-not-need-redirection/10787/5 "2022-02-10T10:05:56Z")

</div>

it’s actually surprisingly easy and has been around for a while, i just never had the chance to try it!  
thanks to @jplevyak & @ali.piccioni we have [this](https://github.com/dfinity/icfront).

1. sign up to firebase and create a new project (you can use other services like vercel as well but then you’ll need to change the `makefile`). make sure you add your custom domain to the firebase hosting, in our case `btcflower.xyz`.

2. clone the repo and change line 13 and 14 in the `makefile` from

```auto
read
$EDITOR service-worker/src/sw/http_request.ts 

```

to

```auto
@read EDITOR; \
$$EDITOR service-worker/src/sw/http_request.ts

```

i had to do this so the makefile works in `zsh` and `bash`.

1. next run `make setup`. when the command line prompts

```auto
update CANSTER_ID and MY_DOMAIN in agent-js/apps/sw-cert/src/sw/http_request.ts

```

enter the name of your favourite editor (`vim` for example). this opens an editor where you need to change the `CANISTER_ID` and `MY_DOMAIN` to your respective values. save and close the editor.

1. next we are prompted to setup firebase. choose  
` Hosting: Configure files for Firebase Hosting and (optionally) set up GitHub Action deploys` and then `Use an existing project`. Now you should see and select the project you created in the first step. Keep the public directory at the default `public`, choose `N` when asked about the single-page app and automatic builds and deploys.

2. next you need to run `make build`, this will build the service worker, copy it to the `public` directory and then deploy it with firebase.

3. if you want to change something in the service worker just run `make build` to redeploy it

Now we basically have a `GET` request to our `btcflower.xyz` domain return the service worker to the client. After the service worker is installed in the clients browser, it will then communicate with the asset canister and validate the responses.

This is the same thing that happens when you access a canister through `<canister_id>.ic0.app`, just that now the “boundary node” (boundary nodes can do more than that) is under your control.

Hope that helps, enjoy your custom URLs!

---

<div class="post-metadata">

**Author:** ![bytesun](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/bytesun/32/2682_2.png) [@bytesun](https://forum.dfinity.org/u/bytesun)\
**Post date:** [February 12, 2022, 5:21pm UTC](https://forum.dfinity.org/t/btcflower-xyz-seems-to-be-hosted-on-ic-but-why-this-domain-name-does-not-need-redirection/10787/6 "2022-02-12T17:21:37Z")

</div>

> [@cryptoschindler](#):
>
> buil

thank you for sharing this! I got my domain connected, but got another error as below when I tried to access my custom domain

> Failed to fetch response: TypeError: Failed to execute ‘fetch’ on ‘WorkerGlobalScope’: Illegal invocation

Any idea?

---

<div class="post-metadata">

**Author:** ![3cL1p5e7](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/3cl1p5e7/32/4649_2.png) [@3cL1p5e7](https://forum.dfinity.org/u/3cL1p5e7)\
**Post date:** [February 12, 2022, 5:29pm UTC](https://forum.dfinity.org/t/btcflower-xyz-seems-to-be-hosted-on-ic-but-why-this-domain-name-does-not-need-redirection/10787/7 "2022-02-12T17:29:50Z")

</div>

Are you using service-worker manually?  
I had a similar problem and this is how I solved it. You need to upgrade service-worker code by passing `fetch` to HttpAgent

Steps

- Find `const agent = new HttpAgent({ host: replicaUrl.toString() });`
- And replace

```auto
      const agent = new HttpAgent({
        host: replicaUrl.toString(),
        fetch: self.fetch.bind(self),
      });

```

> <https://github.com/dfinity/ic/pull/5/files#diff-868be50442ee1d9397fa6910d4627c7a0386365ace603123de7ae169ce2de2e4R311>
>
> \### Problem:
> for assets over 2mb size, verification did not pass. This is becau…se the worker only loads and checks the sha256-hashes of the first chunk. Obviously, the hash of the chunk and the hash of the entire file (in \`sha256\` field) do not match.
> 
> \### Solution:
> Make service-worker to load and concat all chunks before hash-check.
> 
> \### Important
> This PR is related, but not blocked by 2 others
> https://github.com/dfinity/agent-js/pull/527
> https://github.com/dfinity/certified-assets/pull/22
> 
> \### Comments:
> \- Now service-worker can check certificates for any assets over 2mb size.
> \- It was necessary to update the \`Jest\` because I caught an error \`Wrong magic number\` when I did \`IDL.encode -\> IDL.decode\`. Current Jest setup corresponds to \`dfinity/agent-js/agent\` setup.
> \- \`fetch: self.fetch.bind(self)\` is passed to \`HttpAgent\` intentionally. See https://github.com/dfinity/agent-js/pull/527
> 
> Waiting for comments on implementation

Hope this helps

---

<div class="post-metadata">

**Author:** ![bytesun](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/bytesun/32/2682_2.png) [@bytesun](https://forum.dfinity.org/u/bytesun)\
**Post date:** [February 12, 2022, 6:10pm UTC](https://forum.dfinity.org/t/btcflower-xyz-seems-to-be-hosted-on-ic-but-why-this-domain-name-does-not-need-redirection/10787/8 "2022-02-12T18:10:04Z")

</div>

@3cL1p5e7 works perfectly!!  
thank you!

---

<div class="post-metadata">

**Author:** ![3cL1p5e7](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/3cl1p5e7/32/4649_2.png) [@3cL1p5e7](https://forum.dfinity.org/u/3cL1p5e7)\
**Post date:** [February 12, 2022, 6:48pm UTC](https://forum.dfinity.org/t/btcflower-xyz-seems-to-be-hosted-on-ic-but-why-this-domain-name-does-not-need-redirection/10787/9 "2022-02-12T18:48:46Z")

</div>

Just in case, I posted a [PR](https://github.com/dfinity/ic/pull/6)  
@frederikrothenberger Is it allowed to publish PR to `dfinity/ic`? I didn’t find any PR from community and it worries me

---

<div class="post-metadata">

**Author:** ![frederikrothenberger](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/frederikrothenberger/32/3826_2.png) [@frederikrothenberger](https://forum.dfinity.org/u/frederikrothenberger)\
**Post date:** [February 15, 2022, 7:46am UTC](https://forum.dfinity.org/t/btcflower-xyz-seems-to-be-hosted-on-ic-but-why-this-domain-name-does-not-need-redirection/10787/10 "2022-02-15T07:46:36Z")

</div>

Hi @3cL1p5e7

Thank you for submitting the PR. Unfortunately, at the current time we do not accept external PRs for the main IC repo. But we are working on it and are planning to accept PR’s for some repos in the near future.

Regarding the actual service worker issue at hand: streaming support is definitely on our radar and we are aware that we need to support this use case in the future.

I will keep you updated regarding future developments of both accepting external contributions and changes to the service worker.

Best regards,  
Frederik

---

<div class="post-metadata">

**Author:** ![3cL1p5e7](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/3cl1p5e7/32/4649_2.png) [@3cL1p5e7](https://forum.dfinity.org/u/3cL1p5e7)\
**Post date:** [February 15, 2022, 9:28am UTC](https://forum.dfinity.org/t/btcflower-xyz-seems-to-be-hosted-on-ic-but-why-this-domain-name-does-not-need-redirection/10787/11 "2022-02-15T09:28:14Z")

</div>

Thank you so much for your reply, Frederik! 💣

---

<div class="post-metadata">

**Author:** ![paulyoung](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/paulyoung/32/5251_2.png) [@paulyoung](https://forum.dfinity.org/u/paulyoung)\
**Post date:** [February 16, 2022, 7:51am UTC](https://forum.dfinity.org/t/btcflower-xyz-seems-to-be-hosted-on-ic-but-why-this-domain-name-does-not-need-redirection/10787/12 "2022-02-16T07:51:15Z")

</div>

> [@frederikrothenberger](#):
>
> Thank you for submitting the PR. Unfortunately, at the current time we do not accept external PRs for the main IC repo.

I suggest adding contribution guidelines stating as much:

> <https://github.com/dfinity/ic/pull/10>
>
> Propose contribution guidelines to inform potential contributors that external P…Rs won’t be accepted at present.
> 
> This information will be surfaced as described in: https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions/setting-guidelines-for-repository-contributors
> 
> Motivated in part by: https://forum.dfinity.org/t/btcflower-xyz-seems-to-be-hosted-on-ic-but-why-this-domain-name-does-not-need-redirection/10787/10?u=paulyoung
