René's URL Explorer Experiment


Title: feat: Cloudflare Workers SSR support — createServerClient + worker-safe analytics by netanelgilad · Pull Request #221 · base44/javascript-sdk · GitHub

Open Graph Title: feat: Cloudflare Workers SSR support — createServerClient + worker-safe analytics by netanelgilad · Pull Request #221 · base44/javascript-sdk

X Title: feat: Cloudflare Workers SSR support — createServerClient + worker-safe analytics by netanelgilad · Pull Request #221 · base44/javascript-sdk

Description: Cloudflare Workers SSR support Motivation Full-stack hosting POC: running app SSR on Cloudflare Workers for Platforms. Today the SDK cannot be safely instantiated inside a Worker request handler: createClient() unconditionally constructs the analytics module, whose heartbeat processor runs a raw setInterval. In Workers, setInterval at global scope throws, and inside a request it leaks past the request lifetime — and there was no config option to disable analytics. axios 1.x adapter auto-detection (xhr → http → fetch) can pick the wrong adapter under workerd. Auth tokens live only in localStorage, so SSR document requests carry no auth at all. Changes Worker-safe analytics (src/modules/analytics.ts): the analytics module is now a no-op outside a browser (typeof window === 'undefined') — no heartbeat interval, no processing timers, track() queues nothing. A new disableAnalytics?: boolean on CreateClientConfig skips analytics explicitly; the server client sets it automatically. Axios adapter passthrough (src/utils/axios-client.ts, src/client.ts): createAxiosClient accepts an optional adapter, exposed as an adapter field on CreateClientConfig and forwarded to all four internal axios clients. The server client forces adapter: 'fetch'. New createServerClient(options) (src/server.ts, exported from the main entry): builds a per-request client for SSR/edge runtimes. Each config value resolves in order: explicit option → env (BASE44_APP_ID, BASE44_API_URL, BASE44_SERVICE_TOKEN, BASE44_FUNCTIONS_VERSION) → the same Base44-* request headers createClientFromRequest reads (so it degrades gracefully behind the existing proxy); the user token resolves option → Authorization: Bearer header → base44_access_token cookie (internal dependency-free cookie parser handles quoted + URL-encoded values). Throws a clear error when no appId resolves or when the serverUrl isn't absolute; forces analytics off, the fetch adapter, and requiresAuth: false — no window/localStorage access anywhere in the path. Also propagates Base44-State like createClientFromRequest. Cookie mirror for browser token storage (src/utils/auth-utils.ts, src/modules/auth.ts): saveAccessToken now also sets a base44_access_token cookie (path=/; SameSite=Lax, plus Secure on https) so subsequent document requests carry the token to SSR; removeAccessToken clears it. auth.setToken() and auth.logout() (which write localStorage inline) mirror/clear the same cookie so login and logout flows stay consistent with SSR. All cookie writes are guarded on typeof document !== 'undefined'; localStorage behavior is byte-for-byte unchanged. Compatibility guarantees Deno backend-functions contract unchanged: createClientFromRequest and its Authorization / Base44-Service-Authorization / Base44-App-Id / Base44-Api-Url / Base44-Functions-Version / Base44-State header handling are untouched. No exports map added to package.json — consumers that deep-import (e.g. @base44/sdk/dist/utils/axios-client) keep working. createServerClient is exported from the main entry only. Browser behavior unchanged when analytics is enabled: same heartbeat, batching, throttling, visibility handling, and initialization event; the no-op path only activates without window or when disableAnalytics is set. Test evidence npm test (typecheck via tsc --noEmit + vitest): 19 files, 197 tests passed (was 15 files / ~171 before this PR). npm run lint (eslint): clean. npm run build (tsc): clean. New coverage: tests/unit/server-client.test.ts: full resolution precedence (options → env → headers), cookie fallback incl. quoted/URL-encoded values, Authorization-over-cookie priority, malformed-header handling, appId-missing throws, non-absolute serverUrl throws, fetch adapter forced on all four axios clients, Base44-State propagation, and a worker simulation proving no timers start and track() is a safe no-op without window. tests/unit/auth-utils-cookie.test.ts: cookie-string builders (attributes, Secure, encoding, custom name, clearing) plus save/remove mirror behavior in a simulated browser and SSR no-op guards. tests/unit/analytics.test.ts: updated to simulate browser globals (analytics is browser-only now) and extended with heartbeat-preserved-in-browser and disableAnalytics no-op tests, plus a no-window worker-safety test. Note: this PR triggers an automatic @base44-preview/sdk npm preview publish for easy testing in the Workers POC. 🤖 Generated with Claude Code https://claude.ai/code/session_01DvhQfqxACcq25XAQRpoSh9 Generated by Claude Code

Open Graph Description: Cloudflare Workers SSR support Motivation Full-stack hosting POC: running app SSR on Cloudflare Workers for Platforms. Today the SDK cannot be safely instantiated inside a Worker request handler: ...

X Description: Cloudflare Workers SSR support Motivation Full-stack hosting POC: running app SSR on Cloudflare Workers for Platforms. Today the SDK cannot be safely instantiated inside a Worker request handler: ...

Opengraph URL: https://github.com/base44/javascript-sdk/pull/221

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:ee9fc198-f6a2-a937-5a3f-5f2b30e7c5ea
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idBD86:2198A9:3649EF:47BA9F:6A4C2534
html-safe-nonceebe34920156da65787b8dbc329e4b4cdce5b352330ada3c460bc68d165785325
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRDg2OjIxOThBOTozNjQ5RUY6NDdCQTlGOjZBNEMyNTM0IiwidmlzaXRvcl9pZCI6IjE5OTE2NDUzNTI3NjgwNTQ1ODAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac14b46cf6038704d7a00cd4adadad471eb2fe4dca2b0fd4b3d06eba1e7f493028
hovercard-subject-tagpull_request:3997800241
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/base44/javascript-sdk/pull/221/files
twitter:imagehttps://avatars.githubusercontent.com/u/3474905?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/3474905?s=400&v=4
og:image:altCloudflare Workers SSR support Motivation Full-stack hosting POC: running app SSR on Cloudflare Workers for Platforms. Today the SDK cannot be safely instantiated inside a Worker request handler: ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None1b6b16d04026f131a36d57e3b01d0f4d26a51800edf48bf5ed0256e0ac905511
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/base44/javascript-sdk git https://github.com/base44/javascript-sdk.git
octolytics-dimension-user_id234699998
octolytics-dimension-user_loginbase44
octolytics-dimension-repository_id939374418
octolytics-dimension-repository_nwobase44/javascript-sdk
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id939374418
octolytics-dimension-repository_network_root_nwobase44/javascript-sdk
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release9ee13484b32cf23e15fde191da4c9aa47d41201c
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/base44/javascript-sdk/pull/221/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fbase44%2Fjavascript-sdk%2Fpull%2F221%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fbase44%2Fjavascript-sdk%2Fpull%2F221%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=base44%2Fjavascript-sdk
Reloadhttps://github.com/base44/javascript-sdk/pull/221/files
Reloadhttps://github.com/base44/javascript-sdk/pull/221/files
Reloadhttps://github.com/base44/javascript-sdk/pull/221/files
Please reload this pagehttps://github.com/base44/javascript-sdk/pull/221/files
base44 https://github.com/base44
javascript-sdkhttps://github.com/base44/javascript-sdk
Notifications https://github.com/login?return_to=%2Fbase44%2Fjavascript-sdk
Fork 9 https://github.com/login?return_to=%2Fbase44%2Fjavascript-sdk
Star 13 https://github.com/login?return_to=%2Fbase44%2Fjavascript-sdk
Code https://github.com/base44/javascript-sdk
Issues 6 https://github.com/base44/javascript-sdk/issues
Pull requests 41 https://github.com/base44/javascript-sdk/pulls
Discussions https://github.com/base44/javascript-sdk/discussions
Actions https://github.com/base44/javascript-sdk/actions
Projects https://github.com/base44/javascript-sdk/projects
Security and quality 0 https://github.com/base44/javascript-sdk/security
Insights https://github.com/base44/javascript-sdk/pulse
Code https://github.com/base44/javascript-sdk
Issues https://github.com/base44/javascript-sdk/issues
Pull requests https://github.com/base44/javascript-sdk/pulls
Discussions https://github.com/base44/javascript-sdk/discussions
Actions https://github.com/base44/javascript-sdk/actions
Projects https://github.com/base44/javascript-sdk/projects
Security and quality https://github.com/base44/javascript-sdk/security
Insights https://github.com/base44/javascript-sdk/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fbase44%2Fjavascript-sdk%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fbase44%2Fjavascript-sdk%2Fissues%2Fnew%2Fchoose
netanelgiladhttps://github.com/netanelgilad
mainhttps://github.com/base44/javascript-sdk/tree/main
claude/session-m669xyhttps://github.com/base44/javascript-sdk/tree/claude/session-m669xy
Conversation 2 https://github.com/base44/javascript-sdk/pull/221
Commits 1 https://github.com/base44/javascript-sdk/pull/221/commits
Checks 6 https://github.com/base44/javascript-sdk/pull/221/checks
Files changed 11 https://github.com/base44/javascript-sdk/pull/221/files
feat: Cloudflare Workers SSR support — createServerClient + worker-safe analytics https://github.com/base44/javascript-sdk/pull/221/files#top
Show all changes 1 commit https://github.com/base44/javascript-sdk/pull/221/files
c1fad7a feat: Cloudflare Workers SSR support — createServerClient + worker-sa… claude Jul 6, 2026 https://github.com/base44/javascript-sdk/pull/221/commits/c1fad7af531e6ac615fb1981fc5d6471641b0c13
Clear filters https://github.com/base44/javascript-sdk/pull/221/files
Please reload this pagehttps://github.com/base44/javascript-sdk/pull/221/files
Please reload this pagehttps://github.com/base44/javascript-sdk/pull/221/files
client.ts https://github.com/base44/javascript-sdk/pull/221/files#diff-25d66d74617fe2e23d7946bd6e3ba95640ab1b9bc8947445d604fc271c7c1f12
client.types.ts https://github.com/base44/javascript-sdk/pull/221/files#diff-7c19772c84026010b6011cf136c00c5c68a39162febd27aba36ae4f6c45fcf40
index.ts https://github.com/base44/javascript-sdk/pull/221/files#diff-a2a171449d862fe29692ce031981047d7ab755ae7f84c707aef80701b3ea0c80
analytics.ts https://github.com/base44/javascript-sdk/pull/221/files#diff-2ccc72753fbf481b2ae26640b8f003b850727f10691a43cc853428965c1c4c33
auth.ts https://github.com/base44/javascript-sdk/pull/221/files#diff-a4b6b46ad0655761b8e8cb3b08e19346cd4d42032f02699d8daf29d03998aeeb
server.ts https://github.com/base44/javascript-sdk/pull/221/files#diff-8a8ae07582c9d433ec8c2e5c4310ff8901e604f4965c5b90a49117ad46c47595
auth-utils.ts https://github.com/base44/javascript-sdk/pull/221/files#diff-5ba545d290df6d6cdf65aeaa975c1a298851237b32144775e3468703ea548743
axios-client.ts https://github.com/base44/javascript-sdk/pull/221/files#diff-3f0812b51b0d60c0bd97a105064988cd4b659486f5832612e2f28b3ed639fa71
analytics.test.ts https://github.com/base44/javascript-sdk/pull/221/files#diff-1790a157a44283e6348be672487b6350913c36db4c5746b4d5d313ef83a8450c
auth-utils-cookie.test.ts https://github.com/base44/javascript-sdk/pull/221/files#diff-57813e3a748754bc25128512dd1daf108505bb3db08edd25e7cf501ea83485b5
server-client.test.ts https://github.com/base44/javascript-sdk/pull/221/files#diff-8b29fa2996ae4dd600d3ad5601341cd69b4e0d04ac687445f7bb70fcd010400b
src/client.tshttps://github.com/base44/javascript-sdk/pull/221/files#diff-25d66d74617fe2e23d7946bd6e3ba95640ab1b9bc8947445d604fc271c7c1f12
View file https://github.com/base44/javascript-sdk/blob/c1fad7af531e6ac615fb1981fc5d6471641b0c13/src/client.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/base44/javascript-sdk/pull/221/{{ revealButtonHref }}
https://github.com/base44/javascript-sdk/pull/221/files#diff-25d66d74617fe2e23d7946bd6e3ba95640ab1b9bc8947445d604fc271c7c1f12
https://github.com/base44/javascript-sdk/pull/221/files#diff-25d66d74617fe2e23d7946bd6e3ba95640ab1b9bc8947445d604fc271c7c1f12
https://github.com/base44/javascript-sdk/pull/221/files#diff-25d66d74617fe2e23d7946bd6e3ba95640ab1b9bc8947445d604fc271c7c1f12
https://github.com/base44/javascript-sdk/pull/221/files#diff-25d66d74617fe2e23d7946bd6e3ba95640ab1b9bc8947445d604fc271c7c1f12
https://github.com/base44/javascript-sdk/pull/221/files#diff-25d66d74617fe2e23d7946bd6e3ba95640ab1b9bc8947445d604fc271c7c1f12
https://github.com/base44/javascript-sdk/pull/221/files#diff-25d66d74617fe2e23d7946bd6e3ba95640ab1b9bc8947445d604fc271c7c1f12
https://github.com/base44/javascript-sdk/pull/221/files#diff-25d66d74617fe2e23d7946bd6e3ba95640ab1b9bc8947445d604fc271c7c1f12
https://github.com/base44/javascript-sdk/pull/221/files#diff-25d66d74617fe2e23d7946bd6e3ba95640ab1b9bc8947445d604fc271c7c1f12
src/client.types.tshttps://github.com/base44/javascript-sdk/pull/221/files#diff-7c19772c84026010b6011cf136c00c5c68a39162febd27aba36ae4f6c45fcf40
View file https://github.com/base44/javascript-sdk/blob/c1fad7af531e6ac615fb1981fc5d6471641b0c13/src/client.types.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/base44/javascript-sdk/pull/221/{{ revealButtonHref }}
https://github.com/base44/javascript-sdk/pull/221/files#diff-7c19772c84026010b6011cf136c00c5c68a39162febd27aba36ae4f6c45fcf40
https://github.com/base44/javascript-sdk/pull/221/files#diff-7c19772c84026010b6011cf136c00c5c68a39162febd27aba36ae4f6c45fcf40
https://github.com/base44/javascript-sdk/pull/221/files#diff-7c19772c84026010b6011cf136c00c5c68a39162febd27aba36ae4f6c45fcf40
src/index.tshttps://github.com/base44/javascript-sdk/pull/221/files#diff-a2a171449d862fe29692ce031981047d7ab755ae7f84c707aef80701b3ea0c80
View file https://github.com/base44/javascript-sdk/blob/c1fad7af531e6ac615fb1981fc5d6471641b0c13/src/index.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/base44/javascript-sdk/pull/221/{{ revealButtonHref }}
https://github.com/base44/javascript-sdk/pull/221/files#diff-a2a171449d862fe29692ce031981047d7ab755ae7f84c707aef80701b3ea0c80
https://github.com/base44/javascript-sdk/pull/221/files#diff-a2a171449d862fe29692ce031981047d7ab755ae7f84c707aef80701b3ea0c80
https://github.com/base44/javascript-sdk/pull/221/files#diff-a2a171449d862fe29692ce031981047d7ab755ae7f84c707aef80701b3ea0c80
https://github.com/base44/javascript-sdk/pull/221/files#diff-a2a171449d862fe29692ce031981047d7ab755ae7f84c707aef80701b3ea0c80
src/modules/analytics.tshttps://github.com/base44/javascript-sdk/pull/221/files#diff-2ccc72753fbf481b2ae26640b8f003b850727f10691a43cc853428965c1c4c33
View file https://github.com/base44/javascript-sdk/blob/c1fad7af531e6ac615fb1981fc5d6471641b0c13/src/modules/analytics.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/base44/javascript-sdk/pull/221/{{ revealButtonHref }}
https://github.com/base44/javascript-sdk/pull/221/files#diff-2ccc72753fbf481b2ae26640b8f003b850727f10691a43cc853428965c1c4c33
https://github.com/base44/javascript-sdk/pull/221/files#diff-2ccc72753fbf481b2ae26640b8f003b850727f10691a43cc853428965c1c4c33
src/modules/auth.tshttps://github.com/base44/javascript-sdk/pull/221/files#diff-a4b6b46ad0655761b8e8cb3b08e19346cd4d42032f02699d8daf29d03998aeeb
View file https://github.com/base44/javascript-sdk/blob/c1fad7af531e6ac615fb1981fc5d6471641b0c13/src/modules/auth.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/base44/javascript-sdk/pull/221/{{ revealButtonHref }}
https://github.com/base44/javascript-sdk/pull/221/files#diff-a4b6b46ad0655761b8e8cb3b08e19346cd4d42032f02699d8daf29d03998aeeb
https://github.com/base44/javascript-sdk/pull/221/files#diff-a4b6b46ad0655761b8e8cb3b08e19346cd4d42032f02699d8daf29d03998aeeb
https://github.com/base44/javascript-sdk/pull/221/files#diff-a4b6b46ad0655761b8e8cb3b08e19346cd4d42032f02699d8daf29d03998aeeb
https://github.com/base44/javascript-sdk/pull/221/files#diff-a4b6b46ad0655761b8e8cb3b08e19346cd4d42032f02699d8daf29d03998aeeb
https://github.com/base44/javascript-sdk/pull/221/files#diff-a4b6b46ad0655761b8e8cb3b08e19346cd4d42032f02699d8daf29d03998aeeb
https://github.com/base44/javascript-sdk/pull/221/files#diff-a4b6b46ad0655761b8e8cb3b08e19346cd4d42032f02699d8daf29d03998aeeb
Please reload this pagehttps://github.com/base44/javascript-sdk/pull/221/files
Please reload this pagehttps://github.com/base44/javascript-sdk/pull/221/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.