我有一个单页应用程序 + API,正在部署到 Vercel。
我目前正在尝试在 vercel.json 中添加一些配置:
/login) to index.html`,以便我可以利用HTML History API(即react-router的浏览器路由器)/api我有一些动态路径的端点(例如/files/[fileId]/[checksum].ts)如何在 Vercel 中创建重写来实现此目的?
我遵循了这里的建议: https: //vercel.com/docs/configuration#routes/advanced/spa-fallback
{
"rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]
}
Run Code Online (Sandbox Code Playgroud)
然而,这确实将具有动态路径的API端点重定向到index.html文件,我只想将其作为API。
有任何想法吗?
您可以使用否定前瞻正则表达式来检查 url 不包含api.
/(?!api\/.*).*/
Run Code Online (Sandbox Code Playgroud)
/(?!api\/.*).*/
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2808 次 |
| 最近记录: |