Nuxt.js: 设置 publicPath 导致找不到页面

Nuxt.js: Setting publicPath Causes Page Not Found

目标

在子目录中设置一个 Nuxt.js 应用到 运行。

问题

点击配置的 publicPath 显示 "This page could not be found" 由 Nuxt.js 清晰呈现,即使检查器显示所有文件都已成功加载。

上下文

nuxt.config.js

build: {
    publicPath: 'https://qa.nicetry.com/apps/nuxt'
}

我 运行 yarn run build 一切正常。

然后,我在浏览器中点击 https://qa.nicetry.com/apps/nuxt,看到可爱的 "This page could not be found" 消息。没有控制台错误。

更令人困惑的是,我在这个指向 https://qa.nicetry.com 的错误页面上点击了 "Back to the home page" link 并且它起作用了。甚至应用程序 link 也能正常工作(即 https://qa.nicetry.com/test/route 实际上应该是 https://qa.nicetry.com/apps/nuxt/test/route)。当我刷新时,一切都按预期中断。

nuxt 2.4.0

您需要设置路由器基地 https://nuxtjs.org/api/configuration-router/#base

export default {
  router: {
    base: '/app/'
  }
}