The vercel.json file is used to configure deployment settings for Vercel, a cloud platform for static sites and serverless functions.
Configuration §
Here’s an example of a basic vercel.json configuration:
{
"version": 2,
"routes": [
{ "src": "/api/(.*)", "dest": "/api/$1" }
]
}
What this does is:
- It sets the version to 2, which is the latest version of Vercel’s configuration format.
- It routes all API requests to the
/apidirectory.
In other words, if you make a request to https://api.forgefx.tools/api/endpoint, it will be routed to https://api.forgefx.tools/api/endpoint.
For more information…
Advanced Configuration
For more advanced configurations, you can add additional settings to your vercel.json file:
For detailed information on advanced Vercel configurations, you can refer to the official Vercel documentation.
Some advanced configuration options include:
- Setting up redirects and rewrites
- Configuring build settings
- Defining environment variables
- Customizing headers
Here’s an example of a more advanced vercel.json configuration:
{
"version": 2,
"builds": [
{
"src": "api/*.js",
"use": "@vercel/node"
},
{
"src": "package.json",
"use": "@vercel/static-build",
"config": {
"buildCommand": "npm run build",
"outputDirectory": "dist"
}
}
],
"routes": [
{
"src": "/api/(.*)",
"dest": "/api/$1"
},
{
"src": "/(.*)",
"dest": "/index.html"
}
]
}