【问题标题】:Expo + React Navigation + Vercel: Deep Linking not workingExpo + React Navigation + Vercel:深度链接不起作用
【发布时间】:2021-08-10 10:56:39
【问题描述】:

我正在使用 expo sdk41、react navigation 5 和 vercel 来部署一个使用 expo build:web 构建的 web-build。

当我在本地开发时,我可以进行深度链接,例如http://localhost:19006/sign-in。但是,当我将其部署到 vercel 并为其分配域名时,深度链接不再起作用。

我已经在执行以下操作,这允许深度链接在开发中发挥作用:

export const linking = {
    prefixes: [Linking.createUrl('/'),
    screens: {
        ...
    }
}

为什么深度链接在开发中有效,而在部署到 vercel 时无效?

如果需要,我很乐意添加更多信息。

【问题讨论】:

    标签: expo react-navigation-v5 vercel


    【解决方案1】:

    运行 expo build:web 会捆绑一个 SPA,您需要将对已部署应用程序的调用重定向到 index.html。 Vercel 允许使用位于项目根目录的vercel.json 配置文件配置重定向。

    在您的 Expo 根目录中添加一个web/ 文件夹,并在web/ 文件夹中创建一个vercel.json 文件,其内容如下:

    {
      "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]
    }
    

    当您运行expo build:web 时,此文件将被复制到web-build 文件夹中。

    【讨论】:

      猜你喜欢
      • 2019-08-27
      • 1970-01-01
      • 2019-09-13
      • 1970-01-01
      • 2017-09-18
      • 1970-01-01
      • 2023-02-25
      • 2020-01-31
      • 2020-12-25
      相关资源
      最近更新 更多