T
TanStack3mo ago
genetic-orange

Proper way return responses from request middleware

if (!signature) {
throw new Response('Missing signature', { status: 400 })
}
if (!signature) {
throw new Response('Missing signature', { status: 400 })
}
is this the conventional way to return a response from request middleware? it doesnt mention in the docs
1 Reply
genetic-orange
genetic-orangeOP3mo ago
e.g
export const sigValidationMiddleware = createMiddleware({type: "request"}).server(
async ({ next, request }) => {
const signature = request.headers.get('x-signature')
if (!signature) {
throw new Response('Missing signature', { status: 400 })
}
export const sigValidationMiddleware = createMiddleware({type: "request"}).server(
async ({ next, request }) => {
const signature = request.headers.get('x-signature')
if (!signature) {
throw new Response('Missing signature', { status: 400 })
}

Did you find this page helpful?