Amplify makes `Failed to load resource: the server responded with a status of 400` error

Viewed 1041

I got this error with Amplify, I finished the build tho.

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

This system can work in the local environment. Package.json script of the local env is this.

  .......
  "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 ."
  },
  .......

My amplify.xml is below.

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/**/*'

The screen is totally brank.

enter image description here

Is there anyone who has the same trouble?

1 Answers

I ran into the same problem and after spending hours troubleshooting, it turned out to be an Amplify CI/CD build configuration problem.

While connecting the repository to the Amplify app, you are prompted to edit the build settings in the amplify.yaml file. For whatever reason, the default value for baseDirectory is set to public.

Download the file, place it in the repository root, and change:

artifacts:
  baseDirectory: public

to

artifacts:
  baseDirectory: build

Commit, push, reconnect the branch and it should work.

Related