【问题标题】:Amplify makes `Failed to load resource: the server responded with a status of 400` errorAmplify 使“加载资源失败:服务器响应状态为 400”错误
【发布时间】:2020-12-21 23:46:37
【问题描述】:

我在使用 Amplify 时遇到了这个错误,我已经完成了构建。

Failed to load resource: the server responded with a status of 400
manifest.json:1 

本系统可以在本地环境下工作。本地环境的Package.json脚本就是这个。

  .......
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "format": "./node_modules/.bin/eslint --fix --ignore-path .gitignore ."
  },
  .......

我的 amplify.xml 在下面。

version: 1
frontend:
    phases:
        preBuild:
            commands: 
                - nvm install 14.15.0
                - nvm use 14.15.0
                - yarn install
        build:
            commands: 
                - nvm install 14.15.0
                - nvm use 14.15.0
                - node -v
                - yarn run build
    artifacts:
        baseDirectory: public
        files:
            - '**/*'
    cache:
        paths:
            - 'node_modules/**/*'

屏幕完全空白。

有人遇到同样的问题吗?

【问题讨论】:

    标签: javascript reactjs amazon-web-services npm aws-amplify


    【解决方案1】:

    我遇到了同样的问题,在花了几个小时进行故障排除后,结果证明这是一个 Amplify CI/CD 构建配置问题。

    将存储库连接到 Amplify 应用时,系统会提示您编辑 amplify.yaml 文件中的构建设置。无论出于何种原因,baseDirectory 的默认值设置为 public

    下载文件,将其放在存储库根目录中,然后进行更改:

    artifacts:
      baseDirectory: public
    

    artifacts:
      baseDirectory: build
    

    提交、推送、重新连接分支,它应该可以工作了。

    【讨论】:

      猜你喜欢
      • 2021-04-12
      • 2022-06-15
      • 1970-01-01
      • 2021-09-25
      • 2016-09-19
      • 2020-09-21
      • 1970-01-01
      • 1970-01-01
      • 2020-10-20
      相关资源
      最近更新 更多