
Security News
MCP Steering Committee Launches Official MCP Registry in Preview
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
@vercel/routing-utils
Advanced tools
@vercel/routing-utils is a utility package designed to help with routing configurations for Vercel deployments. It provides tools to define and manipulate routes, rewrites, redirects, and headers in a structured and efficient manner.
Define Routes
This feature allows you to define custom routes for your application. The 'src' field specifies the incoming request path, and the 'dest' field specifies the destination path.
{
"routes": [
{ "src": "/about", "dest": "/about.html" },
{ "src": "/blog/(.*)", "dest": "/blog/post?slug=$1" }
]
}
Rewrites
Rewrites allow you to map an incoming request path to a different destination path without changing the URL in the browser.
{
"rewrites": [
{ "source": "/old-path", "destination": "/new-path" }
]
}
Redirects
Redirects enable you to redirect an incoming request to a different URL with a specified status code, such as 301 for permanent redirects.
{
"redirects": [
{ "source": "/old-blog", "destination": "/new-blog", "statusCode": 301 }
]
}
Headers
This feature allows you to set custom headers for specific routes. The 'source' field specifies the route, and the 'headers' field contains an array of headers to be set.
{
"headers": [
{ "source": "/api/(.*)", "headers": [ { "key": "Cache-Control", "value": "no-cache" } ] }
]
}
Next.js is a React framework that provides built-in support for routing, rewrites, redirects, and headers. It offers a more comprehensive solution for building server-rendered React applications, including routing utilities similar to @vercel/routing-utils.
Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications. It allows you to define routes, middleware, and custom headers, but requires more manual setup compared to @vercel/routing-utils.
Koa is a new web framework designed by the team behind Express, aiming to be a smaller, more expressive, and more robust foundation for web applications and APIs. It provides similar routing capabilities but with a more modern and modular approach.
Route validation utilities
npm add @vercel/routing-utils
import { normalizeRoutes } from '@vercel/routing-utils';
const { routes, error } = normalizeRoutes(inputRoutes);
if (error) {
console.log(error.code, error.message);
}
import { routesSchema } from '@vercel/routing-utils';
const ajv = new Ajv();
const validate = ajv.compile(routesSchema);
const valid = validate([{ src: '/about', dest: '/about.html' }]);
if (!valid) console.log(validate.errors);
FAQs
Vercel routing utilities
The npm package @vercel/routing-utils receives a total of 359,206 weekly downloads. As such, @vercel/routing-utils popularity was classified as popular.
We found that @vercel/routing-utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.