Vercel Serverless functions
👋 FYI, this note is over 6 months old. Some of the content may be out of date.
On this page
Basic example Jump to heading
With JavaScript Jump to heading
// /api/test.js
const handler = (request, response) => {
response.status(200).json({
body: request.body,
query: request.query,
cookies: request.cookies,
})
}
export default handler
With TypeScript Jump to heading
// /api/test.ts
import { VercelApiHandler } from './types'
const handler: VercelApiHandler = (request, response) => {
response.status(200).json({
body: request.body,
query: request.query,
cookies: request.cookies,
})
}
export default handler
Enabling CORS Jump to heading
https://vercel.com/support/articles/how-to-enable-cors
← Back home