簡體   English   中英

在 AWS Amplify 控制台上部署 Nuxtjs

[英]Deploying Nuxtjs on AWS Amplify Console

我正在使用以下構建設置在 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

如何修改重寫規則來解決這個問題?

知道了。 它是:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM