Skip to content

Commit 1ac7532

Browse files
authored
Add CLI, API, and SDK configuration section to routing rule template (#1434)
## Summary Adds a "Configure via CLI, API, or SDK" section to the `add-api-rewrite-routing-rule` template README, making it actionable for agents and developers who prefer programmatic setup. - CLI example using `vercel routes add` and `vercel routes publish` with the correct flags - Links to the Vercel REST API and SDK docs for adding routing rules
1 parent 03258fb commit 1ac7532

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

cdn/add-api-rewrite-routing-rule/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,23 @@ The generated routing rule provides a basic rewrite structure. Consider customiz
3232
- **Response headers**: Add a `CDN-Cache-Control` header to cache responses at the edge.
3333
- **Cache tags**: Add a `Vercel-Cache-Tag` header to enable targeted cache purging.
3434

35+
## Configure via CLI, API, or SDK
36+
37+
### Vercel CLI
38+
39+
```bash
40+
vercel routes add "API Proxy" \
41+
--src "/api/:path*" \
42+
--src-syntax path-to-regexp \
43+
--action rewrite \
44+
--dest "https://api.example.com/:path*" \
45+
--yes
46+
47+
vercel routes publish --yes
48+
```
49+
50+
Routing rules can also be configured using the [Vercel REST API](https://vercel.com/docs/rest-api/project-routes/add-a-routing-rule) or the [Vercel SDK](https://vercel.com/docs/rest-api/sdk/project-routes/add-a-routing-rule).
51+
3552
## Code-based approach
3653

3754
Routing rules can also be defined in your code for version control. See the [Proxy requests to external origins](https://vercel.com/templates/template/proxy-requests-to-external-origins) template for a code-based approach using `vercel.ts`.

0 commit comments

Comments
 (0)