Re: [w3c/ServiceWorker] consider register a service worker for a sandbox iframe? (#1601)

Yea, i want to create a lib just like the owner said, with which users could pass the html file content and css content or other resources into it, then the iframe could display the html wholely. 

for example, i want to preview this website locally (all the resources are generated locally)
index.html
```html
<link rel="stylesheet" href="style.css">
<div class="red-box"/>
<img src="image.png" />
```
style.css
```css
.red-box {
  width: 100px;
  height: 100px;
  background-color: red;
}
```
image.png
....

For now, when iframe load the html, try to fetch `style.css` or  `image.png`, but it turns out 404, cus the resource files are not under a static file server.

Thanks to `service-worker`, which probvides the ability to proxy the resource fetch, makes the local runtime website preview possible.

But i could not find a elegant way to service the `sandcodebox.html` and `sw.js` for all the lib users, because 1. cross-orgin 2. inline service-worker (using data url to load service-worker) is forbidden. I have to service this 2 files for each lib user's orgin.

I would be very greatful if you could provide some suggestions on this.

 

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1601#issuecomment-1431059760
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/ServiceWorker/issues/1601/1431059760@github.com>

Received on Wednesday, 15 February 2023 10:07:31 UTC