Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@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 544,123 weekly downloads. As such, @vercel/routing-utils popularity was classified as popular.
We found that @vercel/routing-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 9 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.