Skip to content

feat(blob): accept nuxt/server events - #937

Merged
atinux merged 4 commits into
mainfrom
feat/blob-nuxt-server-event
Oct 20, 2026
Merged

atinux merged 4 commits into
mainfrom
feat/blob-nuxt-server-event

Conversation

@benjamincanac

@benjamincanac benjamincanac commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Nuxt 4.6 added nuxt/server, a server import surface that is not tied to h3 or Nitro. This lets blob.serve, blob.handleUpload and blob.handleMultipartUpload be called from a handler defined with its defineEventHandler. Same approach as atinux/nuxt-auth-utils#544.

import { defineEventHandler, getRouterParams } from 'nuxt/server'
import { blob } from 'hub:blob'

export default defineEventHandler(async (event) => {
  const { pathname } = getRouterParams(event)

  event.res.headers.set('Content-Security-Policy', 'default-src \'none\';')
  return blob.serve(event, pathname!)
})

What changed

  • The event type of the three methods and of the driver handleMultipartUpload is widened to BlobEvent = H3Event | RequestEvent. The implementation still goes through h3. On Nitro 2 the event a nuxt/server handler receives is a proxy over the h3 event, so the h3 helpers keep working on it.
  • RequestEvent is declared in src/blob/types/event.ts instead of imported, because nuxt/server does not resolve below Nuxt 4.6. The nuxt and @nuxt/kit ranges are untouched.
  • Nothing changes for h3 handlers. Same return values, status codes and headers.
  • pathname handling is unchanged. getRouterParams from nuxt/server returns raw segments and blob.serve already decodes them.

Tests

  • The blob fixture gets nuxt/server routes for upload, serve and multipart, plus an h3 multipart route. The new tests compare status, headers and bodies between the two handler styles.
  • The playground gets the same three routes under server/api/nuxt-server/blob.
  • With a fake BLOB_READ_WRITE_TOKEN, the Vercel driver's handleMultipartUpload generates a client token from both handler styles. No real upload to Vercel was made.
  • On Nuxt 4.3.1, with @nuxt/kit and @nuxt/schema pinned to 4.3.1, the packed module installs, typechecks, builds and serves h3 upload, serve and multipart routes.

Notes

  • main already moved the playground to Nuxt 4.6.2, so this PR no longer touches package.json or the lockfile.
  • Nuxt 5 is out of scope. The module still imports h3 v1, and handleMultipartUpload writes the response itself instead of returning a Response.
  • The docs type the event param of serve, handleUpload and handleMultipartUpload as H3Event | RequestEvent and show a nuxt/server example for serve.
  • The path traversal test from fix(blob): validate and encode blob pathnames #938 also runs against the nuxt/server serve route.

@vercel

vercel Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
nuxthub Ready Ready Preview Oct 20, 2026 10:16am UTC

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
playground 780b3e9 Commit Preview URL

Branch Preview URL
Oct 20 2026, 10:14 AM

ampagent and others added 2 commits October 20, 2026 10:13
…-event

Amp-Thread-ID: https://ampcode.com/threads/T-01a158c6-4817-7098-86c6-d7e2da6ee322

# Conflicts:
#	playground/package.json
#	pnpm-lock.yaml
#	src/blob/lib/storage.ts
#	test/blob.test.ts
Also check path traversal through the `nuxt/server` serve route.

Amp-Thread-ID: https://ampcode.com/threads/T-01a158c6-4817-7098-86c6-d7e2da6ee322
Co-authored-by: Sebastien Chopin <[email protected]>
@pkg-pr-new

pkg-pr-new Bot commented Oct 20, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@nuxthub/core@937

commit: 780b3e9

@atinux

atinux commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Thank you for the PR!

@atinux
atinux merged commit df53127 into main Oct 20, 2026
10 checks passed
@atinux
atinux deleted the feat/blob-nuxt-server-event branch October 20, 2026 12:56

This branch was successfully deployed

1 active deployment
Preview — 780b3e96 Deployed Oct 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants