-
Notifications
You must be signed in to change notification settings - Fork 307
Infra/10617 storybook service worker proxy poc #10632
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
base: develop
Are you sure you want to change the base?
Conversation
…fy requests made by Storybook components.
@@ -35,7 +35,7 @@ const path = require( 'path' ); | |||
* Internal dependencies | |||
*/ | |||
const storybookConfig = require( '../../storybook/main' ); | |||
const rootURL = 'file:///src/dist/iframe.html?id='; | |||
const rootURL = 'http://localhost:8001/iframe.html?id='; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to serve via HTTP for Chromium to provide support for service workers.
self.addEventListener( 'fetch', ( event ) => { | ||
const url = new URL( event.request.url ); | ||
|
||
// Check if this is the Google Sign-In script. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've hardwired a check for the SiWG script for the PoC, but this could be adapted to be config-driven for easier reuse.
@@ -115,6 +119,18 @@ InvalidClientID.decorators = [ | |||
export const Empty = Template.bind( null ); | |||
Empty.storyName = 'Empty'; | |||
|
|||
function WithServiceWorker( { children } ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the service worker registration should be applied in WithServiceWorker
instead of globally. This WithServiceWorker
component should be extracted for potential reuse.
Summary
Proof of concept for a proxy that allows intercepting requests made by Storybook components, targeting the https://accounts.google.com/gsi/client request in order to add the
hl=en
query parameter, ensuring the SiWG preview button is rendered in English regardless of the host IP's geo-location.Addresses issue:
Relevant technical choices
PR Author Checklist
Do not alter or remove anything below. The following sections will be managed by moderators only.
Code Reviewer Checklist
Merge Reviewer Checklist