Title: refactor(local-runner): one run endpoint for dynamic apps, cloud by default by jamesbhobbs · Pull Request #465 · deepnote/deepnote · GitHub
Open Graph Title: refactor(local-runner): one run endpoint for dynamic apps, cloud by default by jamesbhobbs · Pull Request #465 · deepnote/deepnote
X Title: refactor(local-runner): one run endpoint for dynamic apps, cloud by default by jamesbhobbs · Pull Request #465 · deepnote/deepnote
Description: Summary
serveStatic — the machinery behind dynamic apps — exposed two run routes: POST /api/run for a local kernel and POST /api/run-cloud for Deepnote. Every app built on it therefore needed two buttons, two response shapes to render, and a decision from the user about where a run should happen before anything could run at all.
This collapses them into one POST /api/run whose destination is a server setting, defaulting to Deepnote Cloud.
await serveStatic({
dir: "./public",
notebookPath: "dashboard.deepnote",
// runTarget: "local", // omit for Deepnote Cloud
});
Before
After
Routes
/api/run + /api/run-cloud
/api/run
Choosing where
the user, per click
runTarget, cloud unless set
Response
two shapes
one, tagged with target
Buttons in run-app
Run + Run in cloud
Run
GET /api/info now reports runTarget alongside the input blocks, so a page can label its Run button without being told separately — run-app uses this to say "Running in Deepnote Cloud…" or "Running in a local kernel…" from one handler.
Security: the guard follows what it protects
The cross-origin guard stayed tied to what it protects rather than to a route name. A cloud run spends the token and can create project content as a side effect, so it keeps the guard; a local run does neither and keeps the looser rule it had on its own route:
if (runTarget === 'cloud' && rejectCrossOriginRequest(req, res)) return
Both directions are pinned by tests — a foreign origin still gets 403 against a cloud-targeted server, and still gets through to a local one — so folding the routes together can't silently tighten or loosen it.
Behaviour change in the example
run-app now runs in Deepnote Cloud by default and wants DEEPNOTE_TOKEN; RUN_TARGET=local restores the local-kernel path and its OPENAI_API_KEY requirement. serve.mjs turns that env var into runTarget, so the option is visible in the example rather than only in the docs.
Local responses now state success: true rather than implying it, so a page reads one field for both targets instead of inferring "no news is good news" from the shorter local response.
Breaking change
POST /api/run-cloud is gone. Callers that ran in the cloud now POST to /api/run against a server using the default runTarget; callers that ran locally pass runTarget: 'local'. serveStatic has no consumers outside this repo's run-app example, which is updated here.
cloudRunner is gone too — the two runner seams are now one RunnerFn:
type RunnerFn = (input, inputs, options?: RunOptions) => Promise
Open Graph Description: Summary serveStatic — the machinery behind dynamic apps — exposed two run routes: POST /api/run for a local kernel and POST /api/run-cloud for Deepnote. Every app built on it therefore needed two b...
X Description: Summary serveStatic — the machinery behind dynamic apps — exposed two run routes: POST /api/run for a local kernel and POST /api/run-cloud for Deepnote. Every app built on it therefore needed two b...
Opengraph URL: https://github.com/deepnote/deepnote/pull/465
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/commits/:range(.:format) |
| route-controller | pull_requests |
| route-action | commits |
| fetch-nonce | v2:6f877746-a981-308b-54c0-a04843c2a782 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C0B4:160D9D:A38253:DEC8E0:6AEDCDBB |
| html-safe-nonce | d01611946c2e323dca2fcbc39d034b1d7a6d3b91a24f44a193cf44619bf89ecd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMEI0OjE2MEQ5RDpBMzgyNTM6REVDOEUwOjZBRURDREJCIiwidmlzaXRvcl9pZCI6IjY1ODM1NzMwNDg0NzA2NTQzOTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 61a617991132351b1ed2d2b04dbbac336538250068d707d090f47e2396fff6ca |
| hovercard-subject-tag | pull_request:4299236853 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/deepnote/deepnote/pull/465/commits/fdabece07e7c15b824e3737877babac728952552 |
| twitter:image | https://avatars.githubusercontent.com/u/15235276?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/15235276?s=400&v=4 |
| og:image:alt | Summary serveStatic — the machinery behind dynamic apps — exposed two run routes: POST /api/run for a local kernel and POST /api/run-cloud for Deepnote. Every app built on it therefore needed two b... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | f60373873bb1ef795e8511ea1f2a76997e9c649d72b02942aedf2def3423a0ce |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/deepnote/deepnote git https://github.com/deepnote/deepnote.git |
| octolytics-dimension-user_id | 45339858 |
| octolytics-dimension-user_login | deepnote |
| octolytics-dimension-repository_id | 1066509034 |
| octolytics-dimension-repository_nwo | deepnote/deepnote |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1066509034 |
| octolytics-dimension-repository_network_root_nwo | deepnote/deepnote |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 0f55cfa61438c7dc93d1024a1e5e5182b36830e2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width