Server entry point and native context
Request parsing and bundled CORS exports from @akshatowo/radical/server.
getNativeContext(request)
| Reader behavior | Contract |
|---|---|
| Result | Effect<NativeContext> without typed failure |
| Precedence | x-radical-context header whenever present; otherwise radical-context cookie |
| Invalid URI or schema | Browser context |
| Trust | No authentication or origin check |
| Field | Native value | Browser value |
|---|---|---|
platform | "android" or "ios" | "browser" |
safeArea | { top, right, bottom, left } | Zero insets |
shellVersion | Nonempty string | null |
Insets are finite, nonnegative CSS pixel values. Native context is untrusted presentation data.
withBundledRequests(handler, outputs?)
Returns a Promise-based fetch handler. Allows credentialed CORS for https://localhost and capacitor://localhost only. Other callers retain the handler's normal behavior without a CORS grant.
| CORS contract | Value |
|---|---|
handler | Request to Response | Promise<Response> |
outputs | Pick<AdapterOutputs, "exposedHeaders">; defaults to {} |
| Allowed preflight | 204; bypasses handler |
| Allowed methods | GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS |
| Allowed request headers | Requested headers |
Preflight Vary | Origin, Access-Control-Request-Headers |
Handler response Vary | Appends Origin for every caller |
| Response header exposure | Appends supplied outputs.exposedHeaders for allowed origins; preserves existing headers |
| Empty or omitted exposed headers | Adds none |
The TanStack Start wrapper from @akshatowo/radical/tanstack-start-server supplies the adapter outputs. It exposes x-tss-serialized, x-tss-raw, and x-tss-error to bundled clients.
The wrapper does not authenticate callers or replace the framework's CSRF configuration.
Other server exports
safeAreaStyle(context?, mode?) returns the document CSS variables. Missing context uses browser defaults. SafeArea is an exported type. NativeContext is available from @akshatowo/radical/native-context.
@akshatowo/radical/native-context exports the context schemas, cookie and header constants, encodeNativeContextCookie, safeAreaStyle, zeroSafeArea, and context types. encodeNativeContextCookie returns an Effect encoding a shell context as URI-encoded JSON.
Source: bundled CORS implementation, server entry, context module.