]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
docs: add history mode vercel example (#1370)
authorqixiao <34623348+qixiaobro@users.noreply.github.com>
Wed, 20 Apr 2022 14:01:29 +0000 (22:01 +0800)
committerGitHub <noreply@github.com>
Wed, 20 Apr 2022 14:01:29 +0000 (16:01 +0200)
docs/guide/essentials/history-mode.md
docs/zh/guide/essentials/history-mode.md

index 1ccd4559db6fd6201ed6846c8c71ed2f3bc133fc..d0e95a67d3af85d42f9cd81315609db207e2edd5 100644 (file)
@@ -172,6 +172,16 @@ In vue-cli, nuxt, and vite projects, this file usually goes under a folder named
 
 You can more about the syntax on [Netlify documentation](https://docs.netlify.com/routing/redirects/rewrites-proxies/#history-pushstate-and-single-page-apps). You can also [create a `netlify.toml`](https://docs.netlify.com/configure-builds/file-based-configuration/) to combine _redirections_ with other Netlify features.
 
+### Vercel
+
+Create a `vercel.json` file under the root directory of your project with the following:
+
+```json
+{
+  "rewrites": [{ "source": "/:path*", "destination": "/index.html" }]
+}
+```
+
 ## Caveat
 
 There is a caveat to this: Your server will no longer report 404 errors as all not-found paths now serve up your `index.html` file. To get around the issue, you should implement a catch-all route within your Vue app to show a 404 page:
index 1f9d5139166bc8cb72c5181d13498e6e7735c57c..98a7bd199d06206b76ce429f42851457136f9131 100644 (file)
@@ -167,6 +167,16 @@ rewrite {
 
 你可以在 [Netlify 文档](https://docs.netlify.com/routing/redirects/rewrites-proxies/#history-pushstate-and-single-page-apps)中找到更多关于语法的信息。你也可以[创建一个 `netlify.toml`](https://docs.netlify.com/configure-builds/file-based-configuration/) 来结合其他 Netlify 功能的重定向。
 
+### Vercel
+
+在项目根目录创建一个`vercel.json`文件,内容如下:
+
+```json
+{
+  "rewrites": [{ "source": "/:path*", "destination": "/index.html" }]
+}
+```
+
 ## Caveat
 
 这有一个注意事项。你的服务器将不再报告 404 错误,因为现在所有未找到的路径都会显示你的 `index.html` 文件。为了解决这个问题,你应该在你的 Vue 应用程序中实现一个万能的路由来显示 404 页面。