Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce ServiceWorker to intercept normal HTTP req/res #58

Closed
whitphx opened this issue Aug 2, 2022 · 1 comment
Closed

Introduce ServiceWorker to intercept normal HTTP req/res #58

whitphx opened this issue Aug 2, 2022 · 1 comment

Comments

@whitphx
Copy link
Owner

whitphx commented Aug 2, 2022

Apart the WebSocket communication, Streamlit also uses many HTTP endpoints for various purposes including serving media files and custom component resources.
To make use of these existing HTTP endpoints and the corresponding client implementations with a minimum amount of changes, it looks like ServiceWorker is a good way, compared to re-implementing these communications on top of WebWorker messaging.

Considerations

@whitphx whitphx changed the title Introduce ServiceWorker to inject normal HTTP req/res Introduce ServiceWorker to intercept normal HTTP req/res Aug 2, 2022
@whitphx
Copy link
Owner Author

whitphx commented Aug 3, 2022

As stated in the second point of the considerations above, ServiceWorker won't work when served from remote origin.
In the case of CRA, it fails into this code block and leads to no effect:

if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
return;
}

@whitphx whitphx closed this as completed Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant