Skip to content

feat: add Endpoint.backend and a split-origin sample - #17927

Open
kachurun wants to merge 1 commit into
eclipse-theia:masterfrom
kachurun:kachurun/split-origin
Open

feat: add Endpoint.backend and a split-origin sample#17927
kachurun wants to merge 1 commit into
eclipse-theia:masterfrom
kachurun:kachurun/split-origin

Conversation

@kachurun

@kachurun kachurun commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

What it does

Lets a Theia frontend live on a different origin than the Node backend (CDN / host app + sandbox API).

Core:

  • Endpoint.backend optionally points REST and WebSocket URLs at another origin. Explicit Endpoint.Options still win.
  • Socket.IO client sends cookies (withCredentials). When THEIA_HOSTS is set, the Socket.IO server uses that list for CORS with credentials.
  • File upload/download send cookies so they work across origins.
  • Mini-browser hostname follows Endpoint.
  • The frontend plugin worker inherits Endpoint.backend from its script URL and loads hostedPlugin from that origin.
    Sample (THEIA_SPLIT_ORIGIN=1, off by default — a normal npm start of the browser example is unchanged):
  • npm run start:split serves a host page at http://localhost:8080/ and Theia static files under /theia/.
  • Preload sets Endpoint.backend from ?backend= and POSTs /split-origin/session with Authorization: Bearer from ?token= before Socket.IO opens. A real app can assign Endpoint.backend at startup and skip the query string.
  • Node does not serve the SPA. The connection cookie is minted only after a successful session POST; WebSocket, file transfer, and /mini-browser then require that cookie.
  • Demo token is S3Cr3t (THEIA_SPLIT_ORIGIN_TOKEN). Wrong or missing token will show loading indicator, session POST returns 401.

Related use cases

How to test

npm run build:browser
npm run start:split
  1. Open http://localhost:8080/. Confirm the host page at / embeds Theia from /theia/?backend=http://localhost:3000&token=S3Cr3t.
  2. Workbench loads, WS connects, explorer / editor work. :3000 must not serve the SPA.
  3. Open a file preview (mini-browser) and upload/download a file — both should hit the backend origin with cookies.
  4. Open the SPA URL with a wrong or missing token. Session POST returns 401, socket does not open.

Follow-ups

Breaking changes

  • This PR introduces breaking changes and requires careful review. If yes, the breaking changes section in the changelog has been updated.

Attribution

Review checklist

Reminder for reviewers

@github-project-automation github-project-automation Bot moved this to Waiting on reviewers in PR Backlog Aug 17, 2026
@kachurun
kachurun force-pushed the kachurun/split-origin branch from 53e9dfe to d787ced Compare August 17, 2026 16:14
Point REST, WebSocket, mini-browser, and file transfer at a remote origin
with cookies. The plugin worker inherits it from its script URL. The sample
serves a host app at / and Theia under /theia/, connects with ?backend=,
and mints the connection cookie only after POST /split-origin/session.

Signed-off-by: Maksim Kachurin <kachurun@gmail.com>
@kachurun
kachurun force-pushed the kachurun/split-origin branch from d787ced to 3d5610c Compare August 17, 2026 16:15
@kachurun kachurun changed the title Kachurun/split origin feat(core): add Endpoint.backend and a split-origin sample Aug 17, 2026
@kachurun kachurun changed the title feat(core): add Endpoint.backend and a split-origin sample feat: add Endpoint.backend and a split-origin sample Aug 17, 2026
@kachurun

Copy link
Copy Markdown
Contributor Author

@sdirix @ndoschek Sorry to bother you, guys, but could you please take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Waiting on reviewers

Development

Successfully merging this pull request may close these issues.

1 participant