Skip to content

createStorageRouteHandlers

createStorageRouteHandlers<T>(options): object

Defined in: packages/storage/src/route-handlers.ts:148

Build loader and action handlers for the /uploads/* route.

The returned pair implements the full opinionated upload + proxy story:

  • loader (GET requests) — streams the R2 object whose key matches params["*"]. If the storage definition declares an ownerCheck for the owning filetype, the check is invoked before streaming and a 403 response is returned on failure. If the URL carries ?token=..., the token is verified against STORAGE_SECRET instead of running ownerCheck (so tokens can be shared without exposing the underlying auth state).
  • action (POST requests) — treats params["*"] as a filetype name, calls storage.handle(name, request, ctx), and returns a JSON body of UploadRouteResult.

T extends StorageSchema

CreateStorageRouteHandlersOptions<T>

Storage instance, auth gate, env resolver, and mount path.

object

{ loader, action } ready to re-export from a splat route module.

action: (args) => Promise<Response>

RouteArgs

Promise<Response>

loader: (args) => Promise<Response>

RouteArgs

Promise<Response>