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

Customizable URL for livebook #901

Closed
LostKobrakai opened this issue Jan 20, 2022 · 4 comments · Fixed by #902
Closed

Customizable URL for livebook #901

LostKobrakai opened this issue Jan 20, 2022 · 4 comments · Fixed by #902

Comments

@LostKobrakai
Copy link

Environment

  • Elixir & Erlang/OTP versions (elixir --version): 1.13.0 / OTP 24
  • Operating system:
  • How have you started Livebook (mix phx.server, livebook CLI, Docker, etc): Docker
  • Livebook version (use git rev-parse HEAD if running with mix): 0.5.0
  • Browsers that reproduce this bug (the more the merrier): Firefox
  • Include what is logged in the browser console:
  • Include what is logged to the server console:

Current behavior

Running the new "Custom Kinos with Elixir and Javascript" livebook I get the following errors in the browser console:

Quellübergreifende (Cross-Origin) Anfrage blockiert: Die Gleiche-Quelle-Regel verbietet das Lesen der externen Ressource auf http://localhost:8080/sessions/u5gmbqsd7tx5u7sy7r4uwq72jkndstq3af75qmch/assets/z6venimgajrd6scpdi4mpphm6y/main.js. (Grund: CORS-Anfrage schlug fehl). Statuscode: (null).

I'm exposing the docker container over VPN to my machine, so I actually access it as http://machinename:8080/….

Expected behavior

Some way to configure livebook to use a custom host or it using the host from the request header.

@josevalim
Copy link
Contributor

I would prefer if we handled this on the client, as Livebook has avoided needing to configure its host so far.

We use iframe srcdoc, which means the iframe has no URL. However, we could inject the <base> tag and make it point to the session path. This means that, inside the iframe, we can load the JavaScript simply as main.js and the user will also be able to load any image or asset they want with relative links.

@jonatanklosko, I don't remember where we landed on loading images and other assets, but this seems to be a fairly elegant solution to both problems. WDYT? Btw, I think we need a new release because I think the iframe won't work on other places such as Fly either.

@jonatanklosko
Copy link
Member

@josevalim we are already using a <base> tag, exactly to handle relative imports, such as CSS and images. The issue is that we are generating session_url on the server, so it includes localhost. I will update it, such that we generate path and add the appropriate host on the client, then we can release a patch!

@LostKobrakai
Copy link
Author

I can confirm it working on my end :)

@jonatanklosko
Copy link
Member

@LostKobrakai fantastic, thanks!

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

Successfully merging a pull request may close this issue.

3 participants