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

improve CORS handling by mini-browser #3589

Open
akosyakov opened this issue Nov 22, 2018 · 4 comments
Open

improve CORS handling by mini-browser #3589

akosyakov opened this issue Nov 22, 2018 · 4 comments
Labels
enhancement issues that are enhancements to current functionality - nice to haves help wanted issues meant to be picked up, require help mini-browser issues related to the mini-browser

Comments

@akosyakov
Copy link
Member

There are 2 cases to consider:

  • opening a URL with http from Theia deployed under https, in this case we should notify a user about CORS issues. Right now they are only logged in the dev tool console and the mini browser is spining forever.
  • opening a URL with https scheme, in this case some pages cannot be opened in iframe (see images below). The mini-browser should detect it and propose a user to open such page in a new browser tab.

screen shot 2018-11-22 at 09 33 40

screen shot 2018-11-22 at 09 33 46

@akosyakov akosyakov added enhancement issues that are enhancements to current functionality - nice to haves help wanted issues meant to be picked up, require help mini-browser issues related to the mini-browser labels Nov 22, 2018
@kittaakos
Copy link
Contributor

#3169 (comment)

@kittaakos
Copy link
Contributor

  • Right now they are only logged in the dev tool console and the mini browser is spining forever

Note, although CORS errors are logged to the Chrome console, they're not visible from the JS code due to security reasons. At least that was my experience; hence there is no special error handling. I hope someone else with more experience finds a solution.

@jankeromnes
Copy link
Member

Random note: projects using webpack-dev-server will often hit iframe errors like this:

  • Adding --host=0.0.0.0 (or using gp forward port) will open the Preview, but just say Invalid Host Header

  • Then adding --disable-host-check (or --allowed-hosts=.example.com) will fix the Browser tab preview, but the iframe Preview will still have a CSP error, because webpack-dev-server specifies frame-ancestors: 'self' (i.e. only "iframe-able" by the same domain)

I don't know why a development web server would be so annoyingly strict about these things, but webpack is very popular these days, so I'm seeing these issues a lot.

@akosyakov
Copy link
Member Author

akosyakov commented Nov 24, 2019

After implementing webviews, I've learned that many websites are secured from embedding them in other websites with X-Frame-Options headers or CSP meta tags. There is no way to work it around.

We could consider to use the headless chrome instead of embedding others web-sites via iframe. It will run as a separate process (so no issues with security) and serve content to us. It's a way how the browser preview extension for VS Code works. Alternatively we can evaluate whether we can replace our mini-browser with this VS Code extension completely. I'm not sure whether it does everything what we need and we want to give up a control over it. Maybe there is a hybrid solution.

cc @svenefftinge

Related to #6562, i.e. it would be good to use webviews while reimplementing the mini-browser to secure it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement issues that are enhancements to current functionality - nice to haves help wanted issues meant to be picked up, require help mini-browser issues related to the mini-browser
Projects
None yet
Development

No branches or pull requests

3 participants