mirror of
https://github.com/afoim/fuwari.git
synced 2026-01-31 09:03:18 +08:00
docs(posts): 更新astro重定向文档以澄清适配器限制
修改文档以强调并非所有适配器都支持透传重定向规则,建议优先使用构建服务商提供的重定向服务
This commit is contained in:
@@ -30,20 +30,4 @@ export default defineConfig({
|
|||||||
|
|
||||||
有的小伙伴就会问了,如果我的Astro输出模式为SSG?那Astro的重定向是不是不支持 `location` 重定向?仅支持 `HTML` 重定向?
|
有的小伙伴就会问了,如果我的Astro输出模式为SSG?那Astro的重定向是不是不支持 `location` 重定向?仅支持 `HTML` 重定向?
|
||||||
|
|
||||||
的确,在不对构建服务商进行额外配置的情况下,Astro会使用兼容模式,创建 `HTML` 重定向,但是我们可以安装构建服务商的适配器(如Vercel)来支持原生的 `location` 重定向。关于 Astro 适配器的更多信息,参见 [配置参考 | Docs](https://docs.astro.build/zh-cn/reference/configuration-reference/#adapter)
|
的确,在不对构建服务商进行额外配置的情况下,Astro会使用兼容模式,创建 `HTML` 重定向,你可以尝试安装适配器来支持重定向,但需要注意 **并不是所有适配器都会透传Astro中设置的重定向规则** ,始终建议使用您构建服务商提供的重定向服务,如配置 `vercel.json` 。关于 Astro 适配器的更多信息,参见 [配置参考 | Docs](https://docs.astro.build/zh-cn/reference/configuration-reference/#adapter)
|
||||||
|
|
||||||
首先安装 Astro 的 Vercel 适配器
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pnpm add @astrojs/vercel
|
|
||||||
```
|
|
||||||
|
|
||||||
接下来在 `astro.config.mjs` 中全局导入并且启用适配器
|
|
||||||
|
|
||||||
```js
|
|
||||||
import netlify from '@astrojs/vercel';
|
|
||||||
{
|
|
||||||
// 示例:使用 Vercel 无服务器部署构建
|
|
||||||
adapter: vercel(),
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|||||||
Reference in New Issue
Block a user