【问题标题】:Deploying Nuxtjs on AWS Amplify Console在 AWS Amplify 控制台上部署 Nuxtjs
【发布时间】:2020-02-15 18:09:11
【问题描述】:

我正在使用以下构建设置在 AWS Amplify 控制台上部署我的 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)

如何修改重写规则来解决这个问题?

【问题讨论】:

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


    【解决方案1】:

    知道了。那是:

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

    【讨论】:

      猜你喜欢
      • 2019-06-05
      • 2020-08-18
      • 2020-06-17
      • 2022-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-01
      • 1970-01-01
      相关资源
      最近更新 更多