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

Storybook on Chrome fails to load due to HSTS forwarded by Vite proxy from Teleport cluster (ERR_SSL_PROTOCOL_ERROR) #32256

Closed
kimlisa opened this issue Sep 20, 2023 · 7 comments
Labels
developer-experience Addressing these issues will improve the experience of developers working on Teleport ui

Comments

@kimlisa
Copy link
Contributor

kimlisa commented Sep 20, 2023

When running yarn storybook, it will auto open browser with http://localhost:9000, at some point with all our upgrades, it stopped working.

Workaround was to use the generated network address or use 127.0.0.1:9000:
image

This happens because when people work on the Web UI through yarn start-teleport, the Vite proxy is served over localhost:3000. The Teleport cluster sends the Strict-Transport-Security header which tells Chrome to use HTTPS for the whole localhost domain.

By going to chrome://net-internals/#hsts, then typing localhost under "Delete domain security policies" and clicking Delete, you can remove this policy from localhost and Storybook will work over http, but once you open a Teleport cluster on localhost, Chrome will require https for localhost again.

We can just one of two solutions:

  1. Use HTTPS for Storybook.
    • Pros:
      • Storybook always works over https.
    • Cons:
      • Requires extra setup as we need to provide the cert and the key as well.
        • We could reuse the cert and key people use for the Vite proxy. That is not ideal as it'd still require other people not familiar with our workflows to set up the cert with mkcert, say backend devs who occasionally do something with Teleport or the design team.
  2. Configure the Vite proxy to overwrite the headers and set Strict-Transport-Security: max-age=0.
    • This should turn off HSTS for localhost.
    • It should be doable by passing the configure field to each proxy target and then calling proxy.on('proxyReq', function(proxyReq, req, res, options) { … }) and setting the header on res. Kind of like in the example with rewriting request headers, but instead we have to rewrite response headers. I'm not 100% sure if this will work.
    • Pros:
      • No setup required before starting Storybook for the first time.
    • Cons:
      • It'll break whenever you access another website over localhost that also sends Strict-Transport-Security.
      • People already affected by this will need to perform a one-time removal of localhost under chrome://net-internals/#hsts anyway.
@kimlisa kimlisa added the ui label Sep 20, 2023
@ravicious
Copy link
Member

I'm not sure if I understand the issue correctly as it never stopped working for me, it always opens http://localhost:9002. 🤔

@ravicious
Copy link
Member

Do you still have this problem with regards to the port? What error do you get?

I recently created another issue for tracking the msw problems specifically. #34450

@kimlisa
Copy link
Contributor Author

kimlisa commented Nov 28, 2023

Do you still have this problem with regards to the port? What error do you get?

I recently created another issue for tracking the msw problems specifically. #34450

yes, it used to work outside of the box, and one day it just stopped working:

image

i wasn't the only one affected. i tried looking into it once, but couldn't figure it out. i also can't run storybook with localhost on cloud either

@kimlisa
Copy link
Contributor Author

kimlisa commented Nov 28, 2023

wait a minute... do you use firefox to dev? i just tried it out on firefox and localhost:9002 works, but chrome doesn't (i've always devved in chrome)

works on firefox/edge, but not chrome/brave

@ravicious ravicious changed the title Fix web dev storybooking Storybook doesn't work on Chrome due to HSTS forwarded by Vite proxy from Teleport cluster Nov 29, 2023
@ravicious ravicious changed the title Storybook doesn't work on Chrome due to HSTS forwarded by Vite proxy from Teleport cluster Storybook on Chrome fails to load due to HSTS forwarded by Vite proxy from Teleport cluster (ERR_SSL_PROTOCOL_ERROR) Nov 29, 2023
@ravicious ravicious added the developer-experience Addressing these issues will improve the experience of developers working on Teleport label Nov 29, 2023
@ravicious
Copy link
Member

I think I've figured it out, I updated the issue description.

I don't have time at the moment to pick the right solution and implement it unfortunately.

@zmb3
Copy link
Collaborator

zmb3 commented Jul 30, 2024

I think we can close this now that storybook uses https, right?

@ravicious
Copy link
Member

Addressed in #44041.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
developer-experience Addressing these issues will improve the experience of developers working on Teleport ui
Projects
None yet
Development

No branches or pull requests

3 participants