在AWS Amplify控制台上部署Nuxtjs

时间:2019-10-18 18:03:34

标签: amazon-web-services nuxt.js aws-amplify nuxt

我正在使用以下构建设置在AWS Amplify Console上部署我的nuxtjs应用:

version: 0.1
frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    build:
      commands:
        - npm run build
  artifacts:
    # IMPORTANT - Please verify your build output directory
    baseDirectory: dist
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

,对于重定向规则,我有以下内容:

[
    {
        "source": "/<*>",
        "target": "/index.html",
        "status": "404",
        "condition": null
    }
]

一切正常,我可以访问SPA应用程序。但是,当我从嵌套URL(例如:example.com/users/23)进行刷新时,我被重定向到example.com/index.html页面,并显示“找不到此页数”错误消息。我知道这可能是因为vue路由器的“历史记录”模式。 (https://router.vuejs.org/guide/essentials/history-mode.html#example-server-configurations

如何修改重写规则以解决此问题?

1 个答案:

答案 0 :(得分:0)

知道了。是:

[ 
   { 
      "source":"</^[^.]+$|.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf|map|json)$)([^.]+$)/>",
      "status":"200",
      "target":"index.html",
      "condition":null
   }
]

相关问题